Google Tag Manager
Implementing tags: Google Analytics
This tutorial will teach you how to deploy a tag with Google Tag Manager.
To get started, click "New Tag" and select the type of tag you’d like to implement from the list.
If there is no tag template available for the type of tag you'd like to use,
click "Custom HTML Tag" and cut and paste the tag code that was provided to you.
We recommend always using a built-in tag template if one is available for your needs.
For this example, select "Google Analytics," then choose "Universal Analytics" as your tag type.
The next step is to configure a trigger that will determine when GTM fires your tag.
In some cases, you’ll want your tag to fire on all pages of your site.
In other cases, you might only want the tag to fire on a subset of pages.
You can also configure more sophisticated triggers that will fire a tag when the user
clicks on an element of a page or submits a form.
For this tag, select “All Pages”.
The next step involves configuring the tag itself.
Enter a memorable name for your tag in the "Tag Name" field.
Enter your Google Analytics tracking ID,
and select the “Page View” track type.
Additional configuration options can also be set as needed
and vary from one tag to another.
Once you’re done, click "Create Tag".
Now add a tag that fires only when the user
completes a given action.
For instance, clicking an 'add to cart' button.
Create another Google Analytics tag, but this time, click "More".
Create a custom trigger by clicking "New".
Then choose a click event.
Add filters to specify which type of clicks should fire the tag.
Start by selecting “Some Clicks”
and add a URL filter to tell Google Tag Manager to listen for clicks on your product pages
Enter the URL of the pages where you want this trigger to work.
Then, add a second filter based on the element ID
and with the value ‘addToCart’.
This will tell Google Tag Manager to fire your tag only when the user clicks on a button
whose ID attribute is ‘addToCart’.
Both trigger filters must be met for the tag to fire.
Give the trigger a descriptive name such as “Click addToCart button” so that you
can re-use this trigger in the future for another tag if you need to.
Set the trigger type to "Click" to ensure that GTM listens for clicks on any page element.
Alternatively, the link click option allows you to create triggers that listen to clicks on anchor tags only.
Next, finish configuring your Google Analytics tag.
Select “Event” as the track type, and populate the event category and the event action.
Leave the event label blank since it’s an optional attribute.
Click "Create," and now you should have a second Google Analytics
tag in your container ready to be published.
One thing to note, even though you might only be using one single Google Analytics
property ID to track your site, you may end up having multiple Google Analytics tags in
Google Tag Manager depending on the different types of events and interactions you would
like to capture.
With all your tags configured, it’s now time to test your container to make sure the
tags fire as expected.
Click "Publish,"
and then “Preview”.
Navigate to your site and you should now see
tags firing as if you had pushed your container to production.
Using the Google Tag Assistant Chrome extension, you can check that the different tags you
had set up are firing correctly.
Once you have thoroughly tested your tags, click "Publish" to push your content of your
container live to all users of your site.
For more information, please visit support.google.com/tagmanager.