In this post I am going to explain how to install google analytics universal with Google Tag Manager.
I am assuming you are familiar with GTM and how this tool can make your life easier but in case you aren’t here a small video from Google discussing some of the key concepts:
Step 1 – Create a Macro for your Google Analytics Property ID
Firstly, you will have to create a macro with your Google Analytics ID. It is not an exaggeration to say that this will be one of the most useful macros you will ever create. I can’t count how many times I started a new Google analytics tag (whether it is a page view or event one) and had to go back to my GA account in order to copy paste the property ID.
By creating this macro, your GA UA-XXXXXXX ID will always be available in the GTM environment for you to use.
Click NEW and from the drop down MENU select “MACRO”
When the Macro Page loads, select the “Constant String” option as shown below:
Name your Macro something that will help you identify that it is your GA ID such as “GoogleAnalyticsPropertyID” and then add your property ID in the Value field.
If you want to set different Google Analytic profiles on your subdomains (for example you have a blog.mywebsite.com and another for your developers such as dev.mywebsite.com) then it is best to use a Lookup Table macro instead the Constant string one.
Step 2 – Create Google Analytics Universal Tag
Go back to the main page, click NEW and then from the drop down menu select “TAG”. Once the new tag opens click on “Tag Type”, scroll down to Google Analytics and select “Universal Analytics” as shown below (click to zoon).
Select that and it will load automatically.
Step 3 – Add Rules
Now you need to tell GTM where you want this tag to fire. Since this is your standard Google Analytics code, you would want this on all your web site’s pages , same way it would work if you hardcode it.
Google Tag Manager gives you one firing rule by default called “All pages”. Select that and then click OK.
Each time you make a change on your tag manager wether it is a new tag, a firing rule or a macro, in order to get it live you will always need to create a new container and publish it. The good news is that Google tag manager stores all your previous versions so in case you make a mistake, you can always roll back to your latest container until you figure out what went wrong.
Step 4 – What about Blocking rules?
In this particular tag you would not really want to block any pages from firing your GA code apart some very special exceptions such as refreshing constantly your pages due to a live blog feature (Link with other post here) in order to avoid multiple pageviews or if you are firing a virtual page views but we will cover that in another post.