Download as pdf or txt
Download as pdf or txt
You are on page 1of 60

Go󰈢g󰇰󰈥 Ta󰈪

Man󰇧󰇫󰈥󰈦
COO KBOO K
Co󰈢k 󰇼󰇴 a 󰈤t󰈢󰇶󰈩
wi󰇹󰇭 t󰇬󰇮󰈤 G󰈓󰉃
Co󰈢k󰇨󰈣o󰈬.
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

“3rd Page View” Cookies 5 Enhanced Ecommerce


Variable Pack 19
AddThis Tracking 7
Exit-intent Tracking 21
AJAX Tracking 9
Facebook Comment Tracking 22
Clean GTM Container 10
File Download Links 23
Cookie Management 11
Form Abandonment 25
Copy Text Tracking 13
GDPR Cookie Consent 26
DISQUS Tracking 14
GTM Wordpress
Drift Tracking 16 (GTM4WP) Container 29

Engagement Timer 17 HTML5 Video Tracking 31

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

Linkedin Tracking 33 Vimeo Tracking 47

Outbound Link Clicks 35 Wistia Tracking 48

Page Load Time 36 Youtube Tracking 49

Pinterest Tracking 37 Zopim (Zendesk) Chat Tracking 51

Print Tracking 39 Mixcloud Tracking 52

Scroll Tracking 41 Soundcloud Tracking Recipe 55

Twitter “Tweet” Tracking 42 Konami Code - Rick Roll 56

UTMZ Cookie Replicator 44

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.

5 Test it out, make sure everything’s working as expected.

6 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 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.

GET THE RECIPE HERE

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.

I NG REDIE N T S DIR ECTI ONS

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.

5 Test it out, make sure everything’s working as expected.

6 Publish when you think everything looks good to go!

REC IP E T IP S

Modify Cookie Expiration

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.

Modify The Number of Page Views

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.

GET THE RECIPE HERE

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

1 Custom 1 Google Analytics 3 Data Layer


HTML Tag Social Tag Variables

1 DOM Ready 1 Custom


Trigger 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 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.

5 Test it out, make sure everything’s working as expected.

6 Publish when you think everything looks good to go!

RE C IPE T IPS

Update With Your Own 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).

I’d recommend using Google Analytics Settings variable instead. Read this guide how to
properly change Tracking ID in the imported container.

You Can Send AddThis interactions as Events (Instead of Social Interactions)

Just edit GA > Event > Social Interaction Tag, change its type to “Event” and assign variables:

Event Category socialAction Event Action socialNetwork

Event Label socialTarget

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.

GET THE RECIPE HERE

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.

I NG RE D IE N TS DIR ECTI ONS

1 Custom 1 Download the container JSON file (right-click on the link


HTML Tag and click “Save Link As” or “Save Target As” to save the
JSON file to your computer).
13 Data Layer 2 Import JSON File into GTM. Log into your own Google Tag
Variables
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.

4 Test it out, make sure everything’s working as expected.

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 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

1 Empty 1 Download the container JSON file (right-click on the


Container link and click “Save Link As” or “Save Target As” to save
the JSON file to your computer).

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.

GET THE RECIPE HERE

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.

I NG RE D IE N TS DIR ECTI ONS

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

Setting a cookie Removing the Same Cookie

Do this by pushing an event to the Do this by pushing an event to the Data


Data layer with the syntax below: layer with the syntax below:

dataLayer.push({ dataLayer.push({

'event': 'setCookie', 'event': 'removeCookie',

'attributes': { 'attributes': {

'cookieName': 'my_cookie_name', 'cookieName': 'my_cookie_name',

'cookieValue': 'my_cookie_value', 'cookieDomain':


'www.myhostname.com',
'cookieDomain':
'www.myhostname.com', 'cookiePath': '/',

'cookiePath': '/', }

'cookieExpires': 1 // Number of });


days - provide a fraction for
periods less than 24 hours

});

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.

GET THE RECIPE HERE

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.

I NG REDIE N T S DIR ECTI ONS

1 Custom 1 Download the container JSON file (right-click on the link


HTML Tag and 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
Event Tag
site. Under Container options, select Import Container.

1 Data Layer 3 Preview to test your container using the preview options
Variables on your site.

4 Test it out, make sure everything’s working as expected.


1 Custom
Event Trigger 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 13
REC IP E T IP S

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).

I’d recommend using Google Analytics Settings variable instead.

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.

GET THE RECIPE HERE

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

1 Google Analytics 1 Custom


Event Tag 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 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 () {

var hasRun = false;

return function () {

this.page.url = 'https://www.yourwebsite.com/page'; // Replace PAGE_URL with


your page's canonical URL variable

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.

6 Test it out, make sure everything’s working as expected.

7 Publish when you think everything looks good to go!

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.

GET THE RECIPE HERE

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

1 Custom 1 Google Analytics 1 Custom


HTML Tag Event Tag 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).

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.

Recommended: Untick the Enable overriding settings in this tag


! checkbox in GA Event Tag and select GA Settings Variable in its
dedicated drop-down field.

4 Preview to test your container using the preview options on your site.

5 Test it out, make sure everything’s working as expected.

6 Publish when you think everything looks good to go!

ENGAGEMENT TIMER
Adds engagement time tracking to every page of your site
which sends events to Google Analytics.

GET THE RECIPE HERE

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

1 Custom 1 Google Analytics 1 Data Layer


HTML Tag Event Tag Variables

1 Custom 4 Constant 1 Built-In


Event Trigger Variables Variable

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.

5 Test it out, make sure everything’s working as expected.

6 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 18
REC IP E T IP S

Update Timer Interval and Limits

Customize how often events fire by editing these variables:

Engagement Timer Engagement Timer Engagement Timer


Interval Milliseconds Idle Milliseconds Limit Seconds

1. How often do we 1. How many seconds of 1. What is the max


send events to inactivity until we amount of seconds we
Google? pause? continue to send
events?
2. (Default – 15000 2. (Default – 65000
milliseconds, or 15 milliseconds, or 65 2. (Default – 1800
seconds) seconds) seconds, or 30
minutes)

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.

GET THE RECIPE HERE

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

1 Pageview 1 Data Layer 12 Java Script


Trigger Variables Variables

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 Add variables to tags, triggers or other variables as needed.

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.

The variables include:

DLV – ecommerce – v1 JS – Product SKU List


JS – Is Purchase JS – Total Product Value
JS – Currency Code JS – Purchase Revenue Total
JS – Ecommerce Step Data JS – Purchase Shipping Amount
JS – Ecommerce Touchpoint Name JS – Purchase Tax Amount
JS – Impressions JS – Purchase Transaction ID
JS – Touchpoint Products

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.

GET THE RECIPE HERE

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.

4 Test it out, make sure everything’s working as expected.

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 21
FACEBOOK COMMENT
TRACKING
You’ll need this recipe to track successful Facebook
comments on your site.

GET THE RECIPE HERE

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 Custom 1 Google Analytics 3 Data Layer


HTML Tag Event Tag Variables

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.

5 Test it out, make sure everything’s working as expected.

6 Publish when you think everything looks good to go!

REC IPE T IPS

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:

Event Category socialAction Event Action socialNetwork

Event Label socialTarget

FILE DOWNLOAD LINKS


This recipe is great for finding out how many people
clicked on the download link in your site.

GET THE RECIPE HERE

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.”

I NG RE D IE N TS DIR ECTI ONS

1 Google 1 Download the container JSON file (right-click on the link


Analytics and click “Save Link As” or “Save Target As” to save the JSON
Event Tag file to your computer).

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.

5 Test it out, make sure everything’s working as expected.

6 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 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.

GET THE RECIPE HERE

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.

I NG RE D IE N TS DIR ECTI ONS

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.

5 Test it out, make sure everything’s working as expected.


6
Publish when you think everything looks good to go!

REC IP E T IP S

Requirements for This Form Abandonment Listener to Work

Form must dispatch a valid form submit event in case of successful submission.

Form must be built with <form> HTML tags.

Form fields must contain name attribute.

This recipe will not work with AJAX forms, multi-page forms or those forms which redirect
to a Thank you page.

Not all browsers support this recipe.

G DPR COOKIE CONSENT


This recipe is useful for cookie banner, triggers and
variables only.
GDPR
GET THE RECIPE HERE

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

1 Custom 1 First Party


HTML Tag Cookie Variable

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:

Pageview – All Pages – Analytics Tracking Allowed


Pageview – All Pages – Functional Cookies Allowed
Pageview – All Pages – Marketing Cookies Allowed
Pageview – DOM Ready – Analytics Tracking Allowed
Pageview – DOM Ready – Functional Cookies Allowed
Pageview – DOM Ready – Marketing Cookies Allowed
Pageview – Window Loaded – Analytics Tracking Allowed
Pageview – Window Loaded – Functional Cookies Allowed
Pageview – Window Loaded – Marketing Cookies Allowed

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.

GET THE RECIPE HERE

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

7 Google Analytics 13 Custom


Event Tags Event Triggers

1 Google Analytics 60 Data Layer


Pageview Tag Variables

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.

Change the GA Tracking ID (UA-XXXXXXX-XX) and other tracking properties (like


e-commerce tracking). Add any custom dimensions you want to track, using the correct
CD numbers.

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.

6 Test it out, make sure everything’s working as expected.

7 Publish when you think everything looks good to go!

REC IP E T IP S

Customize How Frequently Events Fire

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.

GET THE RECIPE HERE

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.

6 Publish when you think everything looks good to go!

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

1 Custom 2 Data Layer 1 Window


HTML Tag Variables Loaded Trigger

1 Custom 1 Google Analytics 1 Custom


Event Trigger Event Tag JavaScript Variable

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.

5 Test it out, make sure everything’s working as expected.

6 Publish when you think everything looks good to go!

LINKE DIN TRACKING


GET THE RECIPE HERE

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

1 Custom 1 Google Analytics 1 Click


HTML Tag Social Tag Trigger

1 Custom 3 Data Layer 1 Built-In


Event Trigger Variables Variable

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.

5 Test it out, make sure everything’s working as expected.

6 Publish when you think everything looks good to go!

REC IPE T IPS

Send Twitter Interactions as Events (Instead of Social Interactions)

Just edit GA > Event > Social Interaction Tag, change its type to “Event” and assign variables:

Event Category socialAction Event Action socialNetwork

Event Label socialTarget

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.

GET THE RECIPE HERE

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

1 Google Analytics 4 Built-In 2 Custom


Event Tag Variables JavaScript
Variable
1 Auto Event 1 Click
Variable 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 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.

5 Test it out, make sure everything’s working as expected.

6 Publish when you think everything looks good to go!

PAGE LOAD TIME


Sometimes you might have a page that takes
forever to load and you might not have a clue. This
recipe uses your page timing data to help you learn
which pages of your site are taking an abnormally
long time to load.

GET THE RECIPE HERE

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

1 Google 1 Download the container JSON file (right-click on the link


Analytics and click “Save Link As” or “Save Target As” to save the JSON
Event Tag file to your computer).

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.

2 Built In 5 Test it out, make sure everything’s working as expected.


Variables
6 Publish when you think everything looks good to go!

PINTEREST TRACKING
This recipe is useful for finding out the pins and
follows of Pinterest on your site.

GET THE RECIPE HERE

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.

I NG RE D IE N TS DIR ECTI ONS

2 Custom 1 Download: First thing you need to do is to download the


HTML Tags container JSON file (right-click on the link and click “Save Link
As” or “Save Target As” to save the JSON file to your
1 Google computer).
Analytics 2 Import JSON File into GTM. Log into your own Google Tag
Social Tag
Manager container and head to the Admin section of the site.
Under Container options, select Import Container.
1 Custom
Event Trigger 3 Update with your own Google Analytics tracking ID. Update
or create a new Constant Variable named
3 Data Layer {{YOUR_GA_TRACKING_ID}} with your Google Analytics
Variables Tracking ID (a.k.a. UA Number).

4 Preview to test your container using the preview options on


2 Click
your site.
Triggers
5
Test it out, make sure everything’s working as expected.
6 Built-In 6 Publish when you think everything looks good to go!
Variable

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:

Event Category socialAction Event Action socialNetwork

Event Label socialTarget

PRINT TRACKING
This recipe is handy for finding out how many users
uses the print function on their browser.

GET THE RECIPE HERE

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

1 Custom 1 Download: First thing you need to do is to download the


Event Tag container JSON file (right-click on the link and click “Save Link
As” or “Save Target As” to save the JSON file to your
1 Google computer).
Analytics 2 Import JSON File into GTM. Log into your own Google Tag
Event Tag
Manager container and head to the Admin section of the site.
Under Container options, select Import Container.
1 Page View
Trigger 3 Update with your own Google Analytics tracking ID. Update
or create a new Constant Variable named
1 Custom {{YOUR_GA_TRACKING_ID}} with your Google Analytics
Event Trigger Tracking ID (a.k.a. UA Number).

4 Preview to test your container using the preview options on


your site.

5 Test it out, make sure everything’s working as expected.

6 Publish when you think everything looks good to go!

REC IP E T IP S

Things to Keep in Mind

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).

It’s set to only run a maximum of once per page!

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.

GET THE RECIPE HERE

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

1 Custom 1 Custom 1 Built In


HTML Tags Event Trigger Variable

1 Google Analytics 2 Data Layer


Event Tag 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.

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.

5 Test it out, make sure everything’s working as expected.

6 Publish when you think everything looks good to go!

REC IP E T IP S

Optional – Update Scroll Breakpoints

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.

GET THE RECIPE HERE

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.

I NG R EDIE N T S DIR ECTI ONS

1 Custom 1 Download: First thing you need to do is to download the


HTML Tag container JSON file (right-click on the link and click “Save
Link As” or “Save Target As” to save the JSON file to your
1 Google computer).
Analytics
2 Import JSON File into GTM. Log into your own Google Tag
Event Tag
Manager container and head to the Admin section of the site.
1 Page Under Container options, select Import Container.
View Trigger 3 Update with your own Google Analytics tracking ID. Update
or create a new Constant Variable named
1 Custom {{YOUR_GA_TRACKING_ID}} with your Google Analytics
Event Trigger Tracking ID (a.k.a. UA Number).

3 Data Layer
4 Preview to test your container using the preview options on
Variables your site.

5 Test it out, make sure everything’s working as expected.


5 Built-In
Variable 6 Publish when you think everything looks good to go!

REC IPE T IPS

Send Twitter Interactions Instead of Events

Just edit GA > Event > Social Interaction Tag, change its type to “Event” and assign variables:

Event Category socialAction Event Action socialNetwork

Event Label socialTarget

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.

GET THE RECIPE HERE

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

1 Custom 8 Custom JavaScript


HTML Tag Variables

2 URL 3 First Party Cookie


Variables 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).

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.

5 Test it out, make sure everything’s working as expected.

6 Publish when you think everything looks good to go!

VIDYARD TRACKING
Find out how many interactions were made with the
embedded Vidyard videos on your site with this recipe.

GET THE RECIPE HERE

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 Page View


HTML Tag Trigger

1 Google Analytics 1 Custom


Event Tag Event Trigger

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.

5 Test it out, make sure everything’s working as expected.

6 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 46
VIMEO TRACKING
Use this recipe to track interactions with embedded
Vimeo videos on your site.

GET THE RECIPE HERE

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

1 Custom 1 Built In 2 Data Layer


HTML Tags Variable Variables

1 Google Analytics 1 Custom


Event Tag Event Trigger

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.

5 Test it out, make sure everything’s working as expected.

6 Publish when you think everything looks good to go!

WISTIA TRACKING
Use this recipe to track interactions with embedded
Wistia videos on your site

GET THE RECIPE HERE

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

1 Custom 1 Google Analytics 1 Built In


HTML Tag Event Tag Variables

1 Custom 2 Data Layer


Event Trigger Variables

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.

5 Test it out, make sure everything’s working as expected.

6 Publish when you think everything looks good to go!

YOUTUBE TRACKING
Find out how many interactions are made with your
embedded Youtube videos with this recipe.

GET THE RECIPE HERE

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 Google 1 Download: First thing you need to do is to download the


Analytics container JSON file (right-click on the link and click “Save Link
Event Tag As” or “Save Target As” to save the JSON file to your
computer).
1 Custom
2 Import JSON File into GTM. Log into your own Google Tag
JavaScript
Manager container and head to the Admin section of the site.
Variable
Under Container options, select Import Container.

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.

5 Test it out, make sure everything’s working as expected.

6 Publish when you think everything looks good to go!

REC IPE T IPS

This Youtube Tracking recipe includes the new Youtube Video Trigger which was introduced
by Google on Sep 13, 2017.

For other Youtube Tracking solutions, check these out:

version 1 (by Bounteous)

version 2 (by Simo Ahava)

version 3 (by Analyticsmania)

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.

GET THE RECIPE HERE

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

1 Custom 5 Built In 1 Data Layer


HTML Tags Variable Variables

1 Google Analytics 1 Custom 1 Page View


Event Tag Event Trigger Trigger

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.

5 Test it out, make sure everything’s working as expected.

6 Publish when you think everything looks good to go!

REC IPE T IPS

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.

GET THE RECIPE HERE

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

1 Custom 1 Download: First thing you need to do is to download the


HTML Tags 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).
1 Google 2 Import JSON File into GTM. Log into your own Google Tag
Analytics Tag
Manager container and head to the Admin section of the site.
Under Container options, select Import Container.
1 Page View
Trigger 3 Update with your own Google Analytics tracking ID. Update
or create a new Constant Variable named
1 Custom {{YOUR_GA_TRACKING_ID}} with your Google Analytics
Event Trigger Tracking ID (a.k.a. UA Number).

3 Data Layer
Variables Embed the correct Mixcloud code:

To add the player widget to your site, select the show


you want to embed, and click the Sharebutton. An
overlay should open with both a Share and an Embed
option. Choose the latter. Setup the player visuals
however you wish. Once you’re done, uncheck the box
next to WordPress, after which the text box should
contain an iframe embed tag.

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.

7 Test it out, make sure everything’s working as expected.

8 Publish when you think everything looks good to go!

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.

GET THE RECIPE HERE

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

1 Custom 1 Page View 1 Custom Event


HTML Tag Trigger Trigger

1 Google 3 Data Layer


Analytics Tag 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.

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.

5 Test it out, make sure everything’s working as expected.

6 Publish when you think everything looks good to go!

KONAMI CODE -
RICK ROLL
It’s not mandatory to use this recipe but it can
be pretty fun to have around.

GET THE RECIPE HERE

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.

5 Test it out, make sure everything’s working as expected.

6 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 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

S O , W H AT ’ S N EXT A F TE R THIS RECI PE BOOK?

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.

AWESOM E NEWS FOR YOU —


WE HAVE M ORE!

Measurement Marketing has a variety


of tools, courses, and workbooks you
can use to improve conversion,
optimize, and scale your business.

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

W.I.N. Google Tag Manager Basics


How to use Google Tag Manager like a
pro even if you’re a complete beginner
How to avoid making big mistakes that
could cost you a ton of time
Things you didn’t know that Google Tag
Manager can actually do for you

LEARN MORE

W.I.N. Google Analytics Basics


Know where your users are coming from...
Know what actions their taking AND the
results of those actions...
And all from one Google Analytics report!

LEARN MORE

W.I.N Traffic Attribution


Which traffic sources is working and
which ones don’t
How to assign value with the result
How other platforms handle attribution

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...

Figuring out how to “know your numbers” is a HUGE pain-in-the-a**, and


most training out there is just too overly-technical.

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

I think Measurement Marketing Academy is the Prior to joining Measurement


missing link for every marketer. Marketing Academy in Feb 2018,
I barely looked at Google Analytics.
Before I made my decision more on gut feeling and Within a year, I've gone from self
how much engagement I could note. Now, I have a described “know nothing” to what my
tool and make my decisions based on data, not on colleagues call a ‘wizard’!
gut. I feel like I found THE missing link.

MEL ANI E S UMMER MERRILL RICHM OND


Facebook @TalkToMerrill,
Younique Media
FMTC.co

You might also like