Professional Documents
Culture Documents
GTM Cookbook
GTM Cookbook
Man
COO KBOO K
Cok a t
wi t G
Coko.
You’ll find a recipe for everything and for those
who are new to GTM recipes, don’t worry about
being lost in translation— these recipes are easy
to digest and follow!
TA B L E O F CO N TENTS
G O O G L E TA G M A N A G E R C O O K B O O K 2
JW Player Tracking 32 Vidyard Tracking 45
G O O G L E TA G M A N A G E R C O O K B O O K 3
RECIPES
Google Tag Manager recipes are basically
ready-made and reusable GTM container with
predefined tags, triggers, and variables that can
be imported with ease.
WHY U S E R E CIP E S?
Imagine constantly setting up new GTM containers for clients or projects— it’s highly likely the tags
and triggers repeat themselves across multiple containers.
Setting up everything from scratch everytime would be a pain, so instead of that, you can import
ready-made solutions like GTM recipes that only require minor adjustments.
STEPS
All recipes have the same steps but with each recipe comes with its own unique twist— different
adjustments. Below are the usual steps needed to use these GTM recipes.
1 Download: First thing you need to do is to download the container JSON file (right-click
on the link and click “Save Link As” or “Save Target As” to save the JSON file to your
computer).
2 Import JSON File into GTM. Log into your own Google Tag Manager container and head
to the Admin section of the site. Under Container options, select Import Container.
3 Adjust the settings accordingly. Each recipe has a different purpose so it would be
required for you to create a tag manually for some containers.
4 Preview to test your container using the preview options on your site.
G O O G L E TA G M A N A G E R C O O K B O O K 4
“3RD PAGE VIEW”
COOKIES
Cookies are crucial on the web. Without cookies, you
wouldn’t be able to use Facebook or Twitter.
Cookies help retain data throughout a user’s visit on
a webpage, making them an important part of web
analytics. You’ll need this recipe to find out how
many page views you’re getting for your pages.
REC I PE C REDI T
https://www.analyticsmania.com/google-tag-manager-recipes/3rd-page-view/
WHAT T H E RECIP E DO E S
This recipe is used to track the number of page views and stores it in the pageviewCount cookie.
When the number is greater or equal to 3, it fires a trigger.
1 Custom 1 Download the container JSON file (right-click on the link and
HTML Tag click “Save Link As” or “Save Target As” to save the JSON file to
your computer).
1 Page View
2 Import JSON File into GTM. Log into your own Google Tag
Trigger
Manager container and head to the Admin section of the site.
Under Container options, select Import Container.
1 1st Party
Cookie 3 Assign any tag you want to the Window Loaded – 3rd Page
Variable View trigger.
G O O G L E TA G M A N A G E R C O O K B O O K 5
Keep in mind that this GTM recipe sets a cookie and creates a trigger only.
! You’ll have to create some kind of tag manually. Few examples: email
pop-up tag, remarketing tag, etc.
4 Preview to test your container using the preview options on your site.
REC IP E T IP S
By default, the cookie expires in 30 days. To change the expiration period, replace number 30.
In the end of the cHTML > Set Cookie > Pageview Counter script > setCookie 30 days.
By default, the trigger in this Google Tag Manager recipe fires on 3rd page view, but you can
edit the number in Window Loaded > 3rd Page View trigger.
G O O G L E TA G M A N A G E R C O O K B O O K 6
ADDTHIS TRACKING
You’ll need this recipe to track clicks of AddThis Social
Sharing widget on your site. Find out how many times
your content has been shared on Facebook, pinned on
Pinterest, or even tweeted on Twitter.
REC I PE C REDI T
https://www.analyticsmania.com/google-tag-manager-recipes/addthis/
WHAT T H E RE CIP E DO ES
Tracks clicks of AddThis Social Sharing widget embedded on your website and sends this data to
Google Analytics as Social Interactions. You won’t see these events in Google Analytics
Real-time reports. They will appear in your Social reports (Acquisition > Social > Plugins) after
24-48 hours, instead.
Other GTM recipes related to social networks (Facebook, Twitter, Pinterest, LinkedIn) are
compatible with this recipe. In order to keep everything optimized, they all use the same
variables and Google Analytics Social tag.
I NG RE D IE N TS
G O O G L E TA G M A N A G E R C O O K B O O K 7
D I REC T IO N S
1 Download the container JSON file (right-click on the link and click “Save Link As” or “Save
Target As” to save the JSON file to your computer).
2 Import JSON File into GTM. Log into your own Google Tag Manager container and head
to the Admin section of the site. Under Container options, select Import Container.
3 Adjust the settings accordingly. Each recipe has a different purpose so it would be required
for you to create a tag manually for some containers.
4 Preview to test your container using the preview options on your site.
RE C IPE T IPS
I’d recommend using Google Analytics Settings variable instead. Read this guide how to
properly change Tracking ID in the imported container.
Just edit GA > Event > Social Interaction Tag, change its type to “Event” and assign variables:
G O O G L E TA G M A N A G E R C O O K B O O K 8
AJAX TRACKING
This recipe is perfect for firing tags after a successful
AJAX-style form submission or when AJAX-requested
resources are available.
REC I PE C REDI T
http://www.lunametrics.com/blog/2015/08/27/ajax-event-listener-google-tag-manager/
WHAT T H E RE CIP E DO ES
This recipe listens for $.ajax requests to come back successful and publishes data about each
request into the data layer.
This recipe is for a listener only. It has no visible effect on your site and does not send data to
Google Analytics or other tools unless you create additional triggers and tags to do so.
G O O G L E TA G M A N A G E R C O O K B O O K 9
CLEAN GTM CONTAINER
GET THE RECIPE HERE
REC I PE C REDI T
https://www.analyticsmania.com/google-tag-manager-recipes/clean-gtm-container/
WHAT T H E RE CIP E DO ES
This Google Tag Manager Recipe includes an empty container. If you need to purge a GTM
container which contains a whole bunch of tags, triggers, and variables, one way to achieve
that is to import an empty JSON container which overwrites all them all.
I NG RE D IE N TS DI REC TI ONS
REC IP E T IP S 2 Import JSON File into GTM. Log into your own
Google Tag Manager container and head to the Admin
After logging into your section of the site. Under Container options, select
Google Tag manager Import Container.
container and heading to
3 Preview to test your container using the preview
the Admin section of the
options on your site.
site. Under container
options, after selecting 4 Test it out, make sure everything’s working as
import container— expected.
choose “Overwrite”
5 Publish when you think everything looks good to go!
import option.
G O O G L E TA G M A N A G E R C O O K B O O K 10
COOKIE MANAGEMENT
You’ll need this recipe to manage cookies by adding
tools to your GTM container for storing and removing
cookies. It will add functionality to your container.
REC I PE C REDI T
https://www.bounteous.com/insights/2017/08/10/cookie-management-recipe-gtm/?ns=l
WHAT T H E RE CIP E DO ES
The Cookie Management recipe allows you to set or remove cookies via data layer pushes.
See the recipe description for details of the information to include in the data layer push.
2 Custom 1 Download the container JSON file (right-click on the link and
HTML Tag click “Save Link As” or “Save Target As” to save the JSON file to
your computer).
2 Custom
2 Import JSON File into GTM. Log into your own Google Tag
Event Trigger
Manager container and head to the Admin section of the site.
Under Container options, select Import Container.
1 Constant
Variable 3 Preview to test your container using the preview options on
your site.
1 Data Layer
4 Test it out, make sure everything’s working as expected.
Variables
5 Publish when you think everything looks good to go!
G O O G L E TA G M A N A G E R C O O K B O O K 11
REC IP E T IP S
dataLayer.push({ dataLayer.push({
'attributes': { 'attributes': {
'cookiePath': '/', }
});
G O O G L E TA G M A N A G E R C O O K B O O K 12
COPY TEXT TRACKING
This recipe is perfect for tracking interactions,
especially to track each time a visitor copies text
from your website.
REC I PE C REDI T
http://dcarlbom.com/google-tag-manager/event-tracking-gtm-when-visitor
-copies-text-from-page/
WHAT T H E RECIP E DO E S
When a visitor copies text from your site, it’s considered as an interaction. This recipe
automatically tracks interactions each time a visitor copies text from your website and sends this
information to Google Analytics (affecting the bounce rate). It passes the copied text as an event
label and page path where the event occurred.
1 Data Layer 3 Preview to test your container using the preview options
Variables on your site.
G O O G L E TA G M A N A G E R C O O K B O O K 13
REC IP E T IP S
DISQUS TRACKING
This recipe is the one for you if you’re looking for an easy
solution to track comments with DISQUS on your site.
REC I PE C REDI T
https://iabramo.com/2015/10/29/track-disqus-comments-using-google-tag-manager/
WHAT T H E RE CIP E DO ES
This GTM recipe was originally by Isaac Abramowitz. This recipe lets you track new comments
from DISQUS and sends that data to Google Analytics (not the actual comments).
I NG RE D IE N TS
1 Custom A DISQUS
HTML Tag Unique Identifier
G O O G L E TA G M A N A G E R C O O K B O O K 14
D I RE C T IO N S
1 Download the container JSON file (right-click on the link and click “Save Link As” or “Save
Target As” to save the JSON file to your computer).
2 Import JSON File into GTM. Log into your own Google Tag Manager container and head
to the Admin section of the site. Under Container options, select Import Container.
3 Update with your own Google Analytics tracking ID. Update or create a new Constant
Variable named {{YOUR_GA_TRACKING_ID}} with your Google Analytics Tracking ID (a.k.a.
UA Number).
4 Open your DISQUS widget’s source code and find the snippet of code below:
window.disqus_config = (function () {
return function () {
this.page.identifier = 'XXXXXXXXX';
Copy the XXXXXXX ID and open tag cHTML - DISQUS Listener in GTM and replace
{{YOUR_UNIQUE_DISQUS_ID}} with the XXXXXXX ID.
5 Preview to test your container using the preview options on your site.
REC IP E T IP S
If you’ve installed Disqus comments with the Wordpress Plugin, this.page.identifier (the key
ingredient for the Disqus tracking to function) may have one of two possible values.
However, when you install a WP plugin, it injects a different script for Disqus and uses
postID + Page URL as a unique identifier. This requires you to modify the listener code and
generate a new kind of identifier.
G O O G L E TA G M A N A G E R C O O K B O O K 15
DRIFT TRACKING
Find out how to track Drift chat widget interactions
and email captures. This recipe will help you
analyze an individual’s user journey further and see
the Drift chat interactions in chronological order
together with the user’s other site behaviors.
REC I PE C REDI T
http://www.ryanpraski.com/drift-google-analytics-tracking/
WHAT T H E RE CIP E DO ES
This recipe allows users to track Drift chat’s interactions and pass the data to Google Analytics.
You can capture the following Drift interactions in GA Events:
Drift chat widget is opened and closed
Drift chat widget sidebar is opened and closed
A user’s email address is captured in the Drift chat widget
A conversation is started and a message sent along with the Drift conversation ID
I NG RE D IE N TS
D I RE C T IO N S
1 Download the container JSON file (right-click on the link and click “Save Link As” or “Save
Target As” to save the JSON file to your computer).
G O O G L E TA G M A N A G E R C O O K B O O K 16
2 Import JSON File into GTM. Log into your own Google Tag Manager container and head to
the Admin section of the site. Under Container options, select Import Container.
3 Update with your own Google Analytics tracking ID. Update or create a new Constant
Variable named {{YOUR_GA_TRACKING_ID}} with your Google Analytics Tracking ID (a.k.a.
UA Number).
Replace the {{YOUR_GA_TRACKING_ID}} with the Constant Variable of the same name
YOUR_GA_TRACKING_ID which contains GA Tracking ID.
4 Preview to test your container using the preview options on your site.
ENGAGEMENT TIMER
Adds engagement time tracking to every page of your site
which sends events to Google Analytics.
REC I PE C REDI T
http://www.lunametrics.com/labs/recipes/engagement-timer/
G O O G L E TA G M A N A G E R C O O K B O O K 17
WHAT T H E RE CIP E DO ES
This tracks events every 15 seconds up to a maximum of 30 minutes and pauses when the page isn’t
the active tab in the browser or when the user is idle for the last 65 seconds.
You can simply customize this recipe’s frequency of firing events by editing these variables:
Engagement Timer Interval Milliseconds
Engagement Timer Idle Milliseconds
Engagement Timer Limit Seconds
I NG RE D IE N TS
D I RE C T IO N S
1 Download the container JSON file (right-click on the link and click “Save Link As” or
“Save Target As” to save the JSON file to your computer).
2 Import JSON File into GTM. Log into your own Google Tag Manager container and
head to the Admin section of the site. Under Container options, select Import
Container.
3
Update with your own Google Analytics tracking ID. Update or create a new Constant
Variable named {{YOUR_GA_TRACKING_ID}} with your Google Analytics Tracking ID
(a.k.a. UA Number).
4 Preview to test your container using the preview options on your site.
G O O G L E TA G M A N A G E R C O O K B O O K 18
REC IP E T IP S
ENHANCED ECOMMERCE
VARIABLE PACK
This recipe is useful for marketers or web
analysts who already have Enhanced Ecommerce
tracking on their website or online store. This
helps them fetch useful variables and makes
them available in Google Tag Manager.
REC I PE C REDI T
https://www.lunametrics.com/labs/recipes/enhanced-ecommerce-variable-pack/
G O O G L E TA G M A N A G E R C O O K B O O K 19
WHAT T H E RE CIP E DO ES
The recipe itself won’t create tags or triggers so you’ll just have more variables which can be
used anywhere else (eg. Facebook Pixel Tag).
I NG RE D IE N TS
D I RE C T IO N S
1 Download the container JSON file (right-click on the link and click “Save Link As” or
“Save Target As” to save the JSON file to your computer).
2 Import JSON File into GTM. Log into your own Google Tag Manager container and head
to the Admin section of the site. Under Container options, select Import Container.
These variables won’t have any effect to your current tracking but they will pr ovide you
with data which enhances other tags with consistent information from the Enhanced
Ecommerce recommended data layer.
G O O G L E TA G M A N A G E R C O O K B O O K 20
EXIT-INTENT TRACKING
The exit-intent tracking recipe is especially useful when
you want to fire custom HTML popups or something else
to prevent visitors from leaving your site.
REC I PE C REDI T
https://www.analyticsmania.com/google-tag-manager-recipes/exit-intent/
WHAT T H E RE CIP E DO ES
This recipe creates a customized trigger that is pushed to dataLayer when a user tries to leave a
page or when their mouse hovers from the browser window.
I NG RE D IE N TS
1 Custom
Event Trigger
D I RE C T IO N S
1 Download the container JSON file (right-click on the link and click “Save Link As” or “Save
Target As” to save the JSON file to your computer).
2 Import JSON File into GTM. Log into your own Google Tag Manager container and head to
the Admin section of the site. Under Container options, select Import Container.
3 Preview to test your container using the preview options on your site.
G O O G L E TA G M A N A G E R C O O K B O O K 21
FACEBOOK COMMENT
TRACKING
You’ll need this recipe to track successful Facebook
comments on your site.
REC I PE C REDI T
https://www.analyticsmania.com/google-tag-manager-recipes/facebook-full/
WHAT T H E RE CIP E DO ES
This recipe tracks successful Facebook comment submissions embedded on your site. All the events
are to Google Analytics as Social Interactions and won’t appear in Google Analytics Real-time reports.
You can find them in your Social reports (Acquisition>Social>Plugins) after a 24-48 hour period.
I NG RE D IE N TS
1 Window 1 Custom
Loaded Trigger Event Trigger
D I RE C T IO N S
1 Download the container JSON file (right-click on the link and click “Save Link As” or “Save
Target As” to save the JSON file to your computer).
2 Import JSON File into GTM. Log into your own Google Tag Manager container and head to
the Admin section of the site. Under Container options, select Import Container.
G O O G L E TA G M A N A G E R C O O K B O O K 22
3 Update with your own Google Analytics tracking ID. Update or create a new Constant
Variable named {{YOUR_GA_TRACKING_ID}} with your Google Analytics Tracking ID
(a.k.a. UA Number).
4
Preview to test your container using the preview options on your site.
If You Wish, You Can Send Facebook Interactions as Events (Instead of Social
Interactions).
Just edit GA > Event > Social Interaction Tag, change its type to “Event” and assign variables:
REC I PE C REDI T
http://www.lunametrics.com/labs/recipes/file-download-links/
G O O G L E TA G M A N A G E R C O O K B O O K 23
WHAT T H E RE CIP E DO ES
This recipe tracks clicks on download links on your site and sends Google Analytics events
accordingly. This recipe also includes tracking for links with the following extensions:
.pdf
.doc & .docx
.xls & .xlsx
.txt
To enable more file extensions, edit the trigger called “Link Click - File Extension Is PDF, XLS,
DOC, or TXT.”
2 Import JSON File into GTM. Log into your own Google Tag
2 Custom
Manager container and head to the Admin section of the site.
JavaScript
Under Container options, select Import Container.
Variables
3 Update with your own Google Analytics tracking ID. Update
3 Built-In or create a new Constant Variable named
Variables {{YOUR_GA_TRACKING_ID}} with your Google Analytics
Tracking ID (a.k.a. UA Number).
1 Link Click
4 Preview to test your container using the preview options on
Variable
your site.
G O O G L E TA G M A N A G E R C O O K B O O K 24
FORM ABANDONMENT
This recipe will come in handy when you need to
track multiple forms on a page and separates your
form abandonment as non-interaction so your
bounce rate is unaffected.
REC I PE C REDI T
https://github.com/lauripiispanen/auto-gtm-form-abandonment
WHAT T H E RE CIP E DO ES
This recipe tracks multiple forms on the same page and sends these events to Google
Analytics in case of form abandonment. The events are set as “non-interaction” so your
bounce rate won’t be affected.
1 Custom 1 Download the container JSON file (right-click on the link and
HTML Tag click “Save Link As” or “Save Target As” to save the JSON file to
your computer).
1 Google 2 Import JSON File into GTM. Log into your own Google Tag
Analytics
Manager container and head to the Admin section of the site.
Event Tag
Under Container options, select Import Container.
2 Data Layer 3 Update with your own Google Analytics tracking ID. Update or
Variables create a new Constant Variable named
{{YOUR_GA_TRACKING_ID}} with your Google Analytics
1 Custom Tracking ID (a.k.a. UA Number).
Event Trigger
G O O G L E TA G M A N A G E R C O O K B O O K 25
4 Preview to test your container using the preview options on your site.
REC IP E T IP S
Form must dispatch a valid form submit event in case of successful submission.
This recipe will not work with AJAX forms, multi-page forms or those forms which redirect
to a Thank you page.
REC I PE C REDI T
https://www.analyticsmania.com/google-tag-manager-recipes/gdpr-cookie-consent/
G O O G L E TA G M A N A G E R C O O K B O O K 26
WHAT T H E RE CIP E DO ES
This recipe installs a cookie consent notification by OneTrust and sets up triggers which respects
visitor’s consent and cookie preferences. However, this doesn’t send data to Google Analytics and
doesn’t automatically adapt to your current GTM setup. After importing everything, it’s still necessary
to manually update your current tags.
I N G R E D IE N TS
D I R E C T IO N S
1 Create a free OneTrust account. It might take up to 48 hours to get it, so register as
soon as possible. Here’s a form that you need to submitand after a while, you’ll get an email
with the confirmation link.
2 Download the container JSON file (right-click on the link and click “Save Link As” or “Save
Target As” to save the JSON file to your computer).
3 Import JSON File into GTM. Log into your own Google Tag Manager container and head
to the Admin section of the site. Under Container options, select Import Container.
4 Set up cookie consent notification, publish changes. Read the first half of this guide
for step-by-step instructions.
5 Update all your tracking tags (which deal with personal data) in Google Tag Manager
by adding one of 3 blocking triggers to them as an exception.
This needs to be done with every single tracking tag (which deals with personal
information), including Google Analytics Pageview, Google Adwords Conversion Tag, etc.
If a tag is related to analytics (e.g. Google Analytics Event tag) then assign Blocking –
Analytics Tracking is Not Allowed trigger as an exception. In case of Adwords tag, use
Blocking – Marketing Cookies are Not Allowed trigger. You get the idea, right?
G O O G L E TA G M A N A G E R C O O K B O O K 27
Here’s how an updated tag triggering could look like of a Universal Analytics tag:
6 Additionally, update all those tags which fire upon Pageview, DOM ready, or Window
Loaded Events.
The important part of this new cookie consent is to hold tracking tags until a visitor gives a
consent to be tracked. Therefore, GA, FB pixel, and other pageview-based tags must be “on
hold” as well. Consequently, standard All Pages trigger becomes irrelevant here.
Firstly, you need to remove all Pageview, DOM Ready, and Window Loaded triggers from
your current tags as they do not respect visitor’s consent. Instead, you need to fire
Pageview-based tags immediately after the consent was given. That’s why assign Custom –
Optanon Consent Updated trigger to all of them. The expected result: Universal Analytics
pageview, Facebook Pixel main code, and others which fire upon page load must not fire
until a visitor gives the consent (by clicking Accept Cookies button, closing the banner, or
scrolling down).
But what happens to pageview tags if a visitor has already given the consent and then
refreshes the page? That’s why you also need to complete the step #5.
7 Add pageview-based triggers which respect the consent settings. This recipe contains
9 pageview-related triggers which are based on separate cookie consent groups:
8 Choose one of them for each tag and assign. For example, Universal Analytics Pageview
Tag should get a Pageview – All Pages – Analytics Tracking Allowed trigger while Facebook
Pixel should get a Pageview – All Pages – Marketing Cookies Allowed trigger, etc.
G O O G L E TA G M A N A G E R C O O K B O O K 28
9 Open GA Event > Cookie Consent Data For The Record tag and set the GA Tracking ID (or
GA Settings Variable).
GTM WORDPRESS
(GTM4WP) CONTAINER
If you’re using WordPress and GTM, it’s highly likely that
the gtm4wp plugin is in your stack. After installing the
plugin and configuring it, you would still have to configure
your GTM container to use all the triggers and variables.
REC I PE C REDI T
https://stuifbergen.com/2018/02/gtm-for-wordpress-gtm4wp-container-with
-google-analytics-tags/
WHAT T H E RECIP E DO E S
This recipe is a container that you can import into your GTM workspace to create tags, triggers,
and variables.
I NG REDIE N T S
G O O G L E TA G M A N A G E R C O O K B O O K 29
D I RE C T IO N S
1 Download the container JSON file (right-click on the link and click “Save Link As” or
“Save Target As” to save the JSON file to your computer).
2 Import JSON File into GTM. Log into your own Google Tag Manager container and head
to the Admin section of the site. Under Container options, select Import Container.
3 If you start from an empty container with no Google Analytics tags, here’s what you
should do:
Import the container into your workspace – and merge it. All tags come in one folder,
neatly organized.
Go to the variables section, find the Google Analytics Settings Variable, and configure
it to suit your needs.
4 If you’re starting from an existing container with Google Analytics tags already in place,
consider:
Disabling the “Page View Tag” – you don’t want to track two pageviews per pageview.
Editing all 4 Google Analytics event tags to use your own GA Settings Variable.
5 Preview to test your container using the preview options on your site.
REC IP E T IP S
Currently, the following items are sent to Google Analytics: Play, Pause and view 25, 50, 75,
and 100% of the video.
G O O G L E TA G M A N A G E R C O O K B O O K 30
HTML5 VIDEO TRACKING
This recipe is useful for tracking user interaction with
video players on your site.
REC I PE C REDI T
https://www.thyngster.com/tracking-html5-videos-gtm/
WHAT T H E RE CIP E DO ES
This recipe automatically tracks the interactions of embedded HTML5 video players on your
site It will fire events to Google Analytics when users Play, Pause, and view 25,50,75 and
100% of the video.
I N G RE D IE N TS
1 Custom
HTML Tag
D I R E C T IO N S
1 Download the container JSON file (right-click on the link and click “Save Link As” or “Save
Target As” to save the JSON file to your computer).
2 Import JSON File into GTM. Log into your own Google Tag Manager container and head to
the Admin section of the site. Under Container options, select Import Container.
3 Update with your own Google Analytics tracking ID. Update or create a new Constant
Variable named {{YOUR_GA_TRACKING_ID}} with your Google Analytics Tracking ID (a.k.a.
UA Number).
4 Preview to test your container using the preview options on your site.
G O O G L E TA G M A N A G E R C O O K B O O K 31
5 Test it out, make sure everything’s working as expected.
JW PLAYER TRACKING
GET THE RECIPE HERE
REC I PE C REDI T
https://www.analyticspros.com/blog/tag-management/gtm-integration-for-jw-player-7/
WHAT T H E RE CIP E DO ES
This recipe automatically tracks interactions with embedded JW Player on your site and sends
events to Google Analytics which affects bounce rate.
The possible events are listed below:
Play
Pause
25%, 50%, 75%, 100%
I N G R E D IE N TS
G O O G L E TA G M A N A G E R C O O K B O O K 32
D I R E C T IO N S
1 Download the container JSON file (right-click on the link and click “Save Link As” or “Save
Target As” to save the JSON file to your computer).
2 Import JSON File into GTM. Log into your own Google Tag Manager container and head
to the Admin section of the site. Under Container options, select Import Container.
3 Update with your own Google Analytics tracking ID. Update or create a new Constant
Variable named {{YOUR_GA_TRACKING_ID}} with your Google Analytics Tracking ID
(a.k.a. UA Number).
4 Preview to test your container using the preview options on your site.
REC I PE C REDI T
https://www.analyticsmania.com/google-tag-manager-recipes/linkedin/
WHAT T H E RE CIP E DO ES
This recipe tracks clicks of the Standard Linkedin Share button embedded on your website and
sends the data to Google Analytics as Social Interactions.
G O O G L E TA G M A N A G E R C O O K B O O K 33
I N G R EDIEN TS
D I REC T IO N S
1 Download the container JSON file (right-click on the link and click “Save Link As” or
“Save Target As” to save the JSON file to your computer).
2 Import JSON File into GTM. Log into your own Google Tag Manager container and head
to the Admin section of the site. Under Container options, select Import Container.
3 Update with your own Google Analytics tracking ID. Update or create a new Constant
Variable named {{YOUR_GA_TRACKING_ID}} with your Google Analytics Tracking ID
(a.k.a. UA Number).
4 Preview to test your container using the preview options on your site.
Just edit GA > Event > Social Interaction Tag, change its type to “Event” and assign variables:
G O O G L E TA G M A N A G E R C O O K B O O K 34
OUTBOUND LINK
CLICKS
This recipe will help you understand what
traffic you’re driving to other sites.
REC I PE C REDI T
http://www.lunametrics.com/labs/recipes/outbound-links/
WHAT T H E RE CIP E DO ES
This recipe tracks clicks on links that point to external domains and sends Google Analytics
events accordingly.
I N G R E D IE N TS
D I RE C T IO N S
1 Download the container JSON file (right-click on the link and click “Save Link As” or
“Save Target As” to save the JSON file to your computer).
2 Import JSON File into GTM. Log into your own Google Tag Manager container and head
to the Admin section of the site. Under Container options, select Import Container.
G O O G L E TA G M A N A G E R C O O K B O O K 35
3 Update with your own Google Analytics tracking ID. Update or create a new Constant
Variable named {{YOUR_GA_TRACKING_ID}} with your Google Analytics Tracking ID (a.k.a.
UA Number).
4 Preview to test your container using the preview options on your site.
REC I PE C REDI T
http://www.lunametrics.com/labs/recipes/page-load-timing/
WHAT T H E RE CIP E DO ES
This recipe adds a Google Analytics event to track when a page has finished loading. It works
by sorting first the Label and you can drill into just the pages that are going over a certain
threshold.This will allow you to figure out which page is acting up.
G O O G L E TA G M A N A G E R C O O K B O O K 36
I NG RE D IE N TS DIR ECTI ONS
2 Import JSON File into GTM. Log into your own Google Tag
1 Custom
Manager container and head to the Admin section of the site.
Event Trigger
Under Container options, select Import Container.
1 Custom 3 Update with your own Google Analytics tracking ID. Update
JavaScript or create a new Constant Variable named
Variable {{YOUR_GA_TRACKING_ID}} with your Google Analytics
Tracking ID (a.k.a. UA Number).
1 Window
4 Preview to test your container using the preview options on
Loaded Trigger
your site.
PINTEREST TRACKING
This recipe is useful for finding out the pins and
follows of Pinterest on your site.
REC I PE C REDI T
https://www.analyticsmania.com/google-tag-manager-recipes/pinterest/
G O O G L E TA G M A N A G E R C O O K B O O K 37
WHAT T H E RE CIP E DO ES
This recipe tracks clicks of the standard Pinterest Save (pins) and Follow buttons embedded on your
site and sends the data to Google Analytics as Social Interactions.
REC IP E T IP S
You won’t see these events in Google Analytics Real-time reports. They will appear in
your Social reports (Acquisition > Social > Plugins) within 24-48 hours.
This Google Tag Manager recipe is fully compatible with other Social Interaction
recipes (e.g. Facebook comments, Twitter or Linkedin) because they all use the same Google
Analytics Social Tag called GA – Social – Social Interaction. Make sure you check them out as well.
G O O G L E TA G M A N A G E R C O O K B O O K 38
You Can Send Pinterest Interactions as Events (Instead of Social Interactions)
Just edit GA > Event > Social Interaction Tag, change its type to “Event” and assign variables:
PRINT TRACKING
This recipe is handy for finding out how many users
uses the print function on their browser.
REC I PE C REDI T
http://www.lunametrics.com/blog/2015/03/12/tracking-print-page-gtm/
WHAT T H E RECIP E DO E S
This recipe tracks your website visitor when they use the browser’s Print function.
It only tracks if the print dialog was initiated but not if the user actually prints the page. When a
user cancels out of the print dialog, it will still get tracked as a print.
G O O G L E TA G M A N A G E R C O O K B O O K 39
I NG RE D IE N TS DIR ECTI ONS
REC IP E T IP S
The Google Tag Manager Recipe requires that you have jQuery on your site.
It works regardless of how the user prints (clicking a print button on your site, right-clicking and
selecting the print option, using the keyboard shortcuts of Ctrl+P (Windows) or CMD+P (Mac), or
using the browser options menu).
G O O G L E TA G M A N A G E R C O O K B O O K 40
SCROLL TRACKING
This recipe is perfect for measuring user scroll
depth on your website pages.
REC I PE C REDI T
http://www.lunametrics.com/labs/recipes/scroll-tracking/
WHAT T H E RE CIP E DO ES
This recipe adds automatic scroll tracking to every page on your site and sends events to Google
Analytics. It basically tracks user scroll depth at the 10%, 25%, 50%, 75%, 90%, and 100% marks
but can be customized. When events are pushed to Google Analytics are set as non-interaction hits,
they won’t affect your bounce rate or time on website/page metrics.
I NG RE D IE N TS
D I RE C T IO N S
1 Download: First thing you need to do is to download the container JSON file (right-click
on the link and click “Save Link As” or “Save Target As” to save the JSON file to your
computer).
2 Import JSON File into GTM. Log into your own Google Tag Manager container and head to
the Admin section of the site. Under Container options, select Import Container.
G O O G L E TA G M A N A G E R C O O K B O O K 41
3 Update with your own Google Analytics tracking ID. Update or create a new Constant
Variable named {{YOUR_GA_TRACKING_ID}} with your Google Analytics Tracking ID (a.k.a.
UA Number).
4 Preview to test your container using the preview options on your site.
REC IP E T IP S
You can customize how often events fire by editing the configuration at the end of the tag “CU –
LunaMetrics Scroll Tracking Plugin”. Read this blog post for more information.
TWITTER “TWEET”
TRACKING
If you want to see how many people retweeted your
content from your site, this recipe is the right one for you.
REC I PE C REDI T
https://www.analyticsmania.com/google-tag-manager-recipes/twitter/
G O O G L E TA G M A N A G E R C O O K B O O K 42
WHAT T H E RECIP E DO E S
This recipe tracks Twitter button clicks on your site such as Tweets, Retweets, Follows, and
Favorites which sends this data to Google Analytics as Social Interactions.
3 Data Layer
4 Preview to test your container using the preview options on
Variables your site.
Just edit GA > Event > Social Interaction Tag, change its type to “Event” and assign variables:
G O O G L E TA G M A N A G E R C O O K B O O K 43
UTMZ COOKIE
REPLICATOR
A UTMZ cookie is a legacy solution previously used by
Google Analytics. You can use this recipe with other tags
and triggers. This recipe is also useful for additional
targeting solutions. You can imitate the _utmz cookie and
upgrade triggers, prefill forms and etc.
REC I PE C REDI T
https://www.lunametrics.com/labs/recipes/utmz-cookie-replicator-for-gtm/
WHAT T H E RE CIP E DO ES
This recipe automatically attempts to determine a visitor’s referring traffic information which
creates information about their source, medium, campaign, content, and term which stores this
information in the cookie.
I NG RE D IE N TS
D I RE C T IO N S
1 Download: First thing you need to do is to download the container JSON file (right-click on
the link and click “Save Link As” or “Save Target As” to save the JSON file to your computer).
G O O G L E TA G M A N A G E R C O O K B O O K 44
2 Import JSON File into GTM. Log into your own Google Tag Manager container and head to
the Admin section of the site. Under Container options, select Import Container.
3 Update with your own Google Analytics tracking ID. Update or create a new Constant
Variable named {{YOUR_GA_TRACKING_ID}} with your Google Analytics Tracking ID (a.k.a.
UA Number)
4 Preview to test your container using the preview options on your site.
VIDYARD TRACKING
Find out how many interactions were made with the
embedded Vidyard videos on your site with this recipe.
REC I PE C REDI T
https://www.analyticsmania.com/post/google-tag-manager-video-tracking/
WHAT T H E RE CIP E DO ES
This recipe automatically tracks interactions with embedded Vidyard videos on your site.
The recipe will fire events to Google Analytics when users play and view a certain
percentage of the video.
G O O G L E TA G M A N A G E R C O O K B O O K 45
I NG RE D IE N TS
1 Custom 1 Built In
JavaScript Variable Variables
3 Data Layer
Variables
D I RE C T IO N S
1 Download: First thing you need to do is to download the container JSON file
(right-click on the link and click “Save Link As” or “Save Target As” to save the JSON file to
your computer).
2 Import JSON File into GTM. Log into your own Google Tag Manager container and head
to the Admin section of the site. Under Container options, select Import Container.
3 Update with your own Google Analytics tracking ID. Update or create a new Constant
Variable named {{YOUR_GA_TRACKING_ID}} with your Google Analytics Tracking ID
(a.k.a. UA Number).
4 Preview to test your container using the preview options on your site.
G O O G L E TA G M A N A G E R C O O K B O O K 46
VIMEO TRACKING
Use this recipe to track interactions with embedded
Vimeo videos on your site.
REC I PE C REDI T
https://www.bounteous.com/insights/2017/04/18/vimeo-tracking-plugin
-google-analytics-and-google-tag-manager/
WHAT T H E RECIP E DO E S
This recipe tracks interactions with embedded Vimeo videos on your site. This auto-event listener will
fire events to Google Analytics when users Play, Pause and view a particular percentage of the video.
I NG REDIE N T S
D I REC T IO N S
1 Download: First thing you need to do is to download the container JSON file (right-click on the
link and click “Save Link As” or “Save Target As” to save the JSON file to your computer).
2 Import JSON File into GTM. Log into your own Google Tag Manager container and head to the
Admin section of the site. Under Container options, select Import Container.
3 Update with your own Google Analytics tracking ID. Update or create a new Constant Variable
named {{YOUR_GA_TRACKING_ID}} with your Google Analytics Tracking ID (a.k.a. UA Number).
G O O G L E TA G M A N A G E R C O O K B O O K 47
4 Preview to test your container using the preview options on your site.
WISTIA TRACKING
Use this recipe to track interactions with embedded
Wistia videos on your site
REC I PE C REDI T
http://www.lunametrics.com/labs/recipes/wistia-video-tracking-for-gtm/
WHAT T H E RE CIP E DO ES
This recipe tracks interactions with the embedded Wistia videos on your site. This auto event
listener fires events to Google Analytics when users Play, Pause, view a particular percentage of
the video and etc.
I NG RE D IE N TS
G O O G L E TA G M A N A G E R C O O K B O O K 48
D I RE C T IO N S
1 Download: First thing you need to do is to download the container JSON file (right-click on
the link and click “Save Link As” or “Save Target As” to save the JSON file to your computer).
2 Import JSON File into GTM. Log into your own Google Tag Manager container and head to
the Admin section of the site. Under Container options, select Import Container.
3 Update with your own Google Analytics tracking ID. Update or create a new Constant
Variable named {{YOUR_GA_TRACKING_ID}} with your Google Analytics Tracking ID (a.k.a.
UA Number)
4 Preview to test your container using the preview options on your site.
YOUTUBE TRACKING
Find out how many interactions are made with your
embedded Youtube videos with this recipe.
REC I PE C REDI T
https://www.analyticsmania.com/google-tag-manager-recipes/youtube-built-in/
WHAT T H E RE CIP E DO ES
This recipe tracks interactions with embedded Youtube videos on your site. It fires events to
Google Analytics when users start the video, pause or view a certain percentage of the video.
G O O G L E TA G M A N A G E R C O O K B O O K 49
I NG REDIE N T S DIR ECTI ONS
1 YouTube 3 Update with your own Google Analytics tracking ID. Update
Video Trigger or create a new Constant Variable named
{{YOUR_GA_TRACKING_ID}} with your Google Analytics
4 Built In Tracking ID (a.k.a. UA Number)
Variables
4 Preview to test your container using the preview options on
your site.
This Youtube Tracking recipe includes the new Youtube Video Trigger which was introduced
by Google on Sep 13, 2017.
G O O G L E TA G M A N A G E R C O O K B O O K 50
ZOPIM (ZENDESK)
CHAT TRACKING
If you have a Zendesk chat embedded on your site and
you’re wondering how many users have interacted with it,
this recipe is ideal for you.
REC I PE C REDI T
https://www.analyticsmania.com/post/zopim-google-tag-manager/
WHAT T H E RE CIP E DO ES
This recipe tracks interactions with the Zopim Chat (Zendesk Chat) widget embedded on
your site which sends events to Google Analytics. The interactions tracked are:
Chat started Chat ended
I NG RE D IE N TS
D I RE C T IO N S
1 Download: First thing you need to do is to download the container JSON file (right-click
on the link and click “Save Link As” or “Save Target As” to save the JSON file to your
computer).
G O O G L E TA G M A N A G E R C O O K B O O K 51
2 Import JSON File into GTM. Log into your own Google Tag Manager container and head
to the Admin section of the site. Under Container options, select Import Container.
3 Update with your own Google Analytics tracking ID. Update or create a new Constant
Variable named {{YOUR_GA_TRACKING_ID}} with your Google Analytics Tracking ID
(a.k.a. UA Number)
4 Preview to test your container using the preview options on your site.
Make sure that cHTML – Zopim Listener tag is fired AFTER the main Zopim widget
script is loaded, otherwise tracking will not work.
M IXCLOUD TRACKING
If you’re trying to find out how many interactions were
made with the Mixcloud player on your site, this recipe
is perfect for you.
REC I PE C REDI T
https://www.simoahava.com/analytics/mixcloud-player-integration-google
-tag-manager/
G O O G L E TA G M A N A G E R C O O K B O O K 52
WHAT T H E RE CIP E DO ES
This recipe automatically tracks interactions with the embedded Mixcloud player on your
site. It will fire events to Google Analytics when users view 25%, 50%, 75% of the audio track.
Other possible events include:
Buffering Ended
Play Error
Pause
I NG RE D IE N TS DIR E C TI ONS
3 Data Layer
Variables Embed the correct Mixcloud code:
G O O G L E TA G M A N A G E R C O O K B O O K 53
4 Edit embedded code. Add a unique ID attribute to the iframe code. It makes much
easier to target the correct player. The code should look like this (notice that id=”myPlayer”
in the 2nd piece of code?).
You can add any ID you want, but make sure it’s unique on that page. Embed this code on
your website.
5 Edit Mixcloud Listener. Open “cHTML – Mixcloud Listener” tag in Google Tag Manager
and edit line 11 of its code. Replace #myPlayer with the very same ID you chose in the 5th
step of this tutorial. This way Mixcloud tracking code will know which player it should
track.
6 Preview to test your container using the preview options on your site.
R E C IP E T IP S
If you have more than one widget on your page you’re looking to track, you would need
to duplicate the relevant code for each player on the page.
G O O G L E TA G M A N A G E R C O O K B O O K 54
SOUNDCLOUD
TRACKING RECIPE
This recipe is perfect for finding out if having
how many users are making interactions with
your Soundcloud player on your site.
REC I PE C REDI T
https://www.simoahava.com/analytics/google-tag-manager-soundcloud-integration/
WHAT T H E RE CIP E DO ES
This recipe automatically tracks interactions with the embedded Soundcloud player on your site.
I NG RE D IE N TS
D I RE C T IO N S
1 Download: First thing you need to do is to download the container JSON file (right-click on
the link and click “Save Link As” or “Save Target As” to save the JSON file to your computer).
2 Import JSON File into GTM. Log into your own Google Tag Manager container and head to
the Admin section of the site. Under Container options, select Import Container.
G O O G L E TA G M A N A G E R C O O K B O O K 55
3 Update with your own Google Analytics tracking ID. Update or create a new Constant
Variable named {{YOUR_GA_TRACKING_ID}} with your Google Analytics Tracking ID
(a.k.a. UA Number).
4 Preview to test your container using the preview options on your site.
KONAMI CODE -
RICK ROLL
It’s not mandatory to use this recipe but it can
be pretty fun to have around.
REC I PE C REDI T
https://www.simoahava.com/gtm-tips/add-konami-code-to-your-site/
WHAT T H E RE CIP E DO ES
This recipe replaces every image on the page with a dancing Rick Astley and plays the song in
the background. Once the code is initiated, the recipe will send an event to Google Analytics so
you’ll be able to see how many visitors know about the code.
G O O G L E TA G M A N A G E R C O O K B O O K 56
I NG RE D IE N TS
1 Custom
HTML Tags
D I RE C T IO N S
1 Download: First thing you need to do is to download the container JSON file (right-click on
the link and click “Save Link As” or “Save Target As” to save the JSON file to your computer).
2 Import JSON File into GTM. Log into your own Google Tag Manager container and head to
the Admin section of the site. Under Container options, select Import Container.
3 Update with your own Google Analytics tracking ID. Update or create a new Constant
Variable named {{YOUR_GA_TRACKING_ID}} with your Google Analytics Tracking ID (a.k.a.
UA Number).
4 Preview to test your container using the preview options on your site.
G O O G L E TA G M A N A G E R C O O K B O O K 57
YO U ’ VE REACH E D
TH E E ND OF THIS
REC I P E BOOK!
Didn’t see a recipe you know or
something didn’t seem right?
Feel free to email us to let us
know what you think or even
better, submit your own recipes!
feedback@measurementmarketing.io
We won’t leave you hanging. In fact, we have so many resources you can check out to
continue your journey to further advance your skills in Google Tag Manager.
G O O G L E TA G M A N A G E R C O O K B O O K 58
W.I.N. COURSES
LEARN MORE
LEARN MORE
LEARN MORE
W H E N YO U KN OW E X ACT LY W HAT’S HAPPENI NG I N YOUR
B US I N E S S , I T’ S E ASIE R TO MAKE A DEC I SI ON
Top marketers know their numbers like the back of their hand. They don't just
know what results they are getting from their marketing but HOW they are
getting those results and make decisions based on numbers. BUT...
F O R T U N AT E LY , T HE R E ’ S A SIMPLER WAY...
Measurement
Marketing Academy
KNOW your numbers
TRUST your numbers
GROW your numbers
LEARN MORE