In this post, I’m going to show you how to install Google Analytics on your website using Google Tag Manager. The goal of GTM is to consolidate all of your tags and make them easy to manage. This means you don’t have to place multiple tracking codes within the source code of your website; instead, you install the Google Tag Manager (GTM) code once, and then place all tracking scripts and configurations within your GTM account. Another advantage to using GTM to manage your tags, is that you get to utilize the data layer, variables, and triggers. Let’s get started.
1) Get Your Google Analytics Property ID
Log into your Analytics account and click on the home tab. Find your website listed, and next to it in gray text and parentheses will be your property id. It will look similar to this UA-XXXXXXXX-X
2) Create a Constant Variable That Will Hold Your Google Analytics Website Property ID
Log into your GTM account and the the left side, click on “Variables” then scroll down to the bottom of the page and under “User-Defined Variables” click on “New.”
3) Set the Variables Settings
- First, let’s give it a name of GoogleAnalyticsTrackingID because this is exactly what it is.
- Second, this variable will not change. So, let’s set the type as “Constant.”
- Next, we need to enter the value that this variable will hold. Since this variable is for our Google Analytics Tracking ID, that is exactly what we will put there. Enter the ID in the “Value” field under “Configure Variable” and click “Create Variable.”
Now if you go back to the bottom of your variables page, you will see your new constant variable.
4) Create and Configure A New Tag
On the left side, click on “Tags” then click the “New” button.
- Name your tag
- Select the product type by click on the “Google Analytics” icon
- For tag type, choose “Universal Analytics” unless you are still using the old Classic Analytics. Click “Continue”
- Now, under “Configure Tag” in the “Tracking ID” box, select the variable that you created in Step 3
- Track type can stay as “Page View”
- Under “Fire On” select “All Pages” because we want to track all pages on the website.
Your settings should like like this…
Next, click “Create Tag” and you’ll be taken to a screen that shows your new completed tag.
5) Prevew and Test/Debug Your Tag
Next we want tot make sure our tag is working properly. So from the current screen, in the top right corner, click on the down arrow next to “Publish” and select “Preview.”
The page will refresh and you will see a message at the top of your screen saying that your are now in preview mode.
Now, we want to browse to our website. Once you are there, will you see a window pop up from the bottom of your screen. This window will tell you which tags are being fired. This is where we want to see the name of our Google Analytics tag.
In our screenshot above, we can see that our Google Analytics tag is firing, so we are good to go.
6) Publish Your Tag
The last step is to go back into your GTM account and publish your take to make it live. In the top right corner, click on “Publish” then on the pop up screen, click “Publish Now.”
You are now ready to go. If you have any questions, please leave a comment below.