To setup your free Google Tag Manager Account, go to https://tagmanager.google.com
Sign up with your Gmail or Google account email address, I used the same email as I use for Google Analytics.
The main reason we setup Google Tag Manager was to have control over when cookies would fire on our website so that visitors have an option to disable the cookies for GDPR compliance.
So we run the following through Google Tag Manager.
– Google Analytics
— Added Scroll event
— Added Custom Dimension Document Referrer (What is Document Referrer (Google Analytics))
– Facebook Pixel Setup (Ultimate Guide to Setup Facebook Pixel with Google Tag Manager)
– Added our own custom checkbox to our comments section for GDPR compliance.
There is so much more you can do with Google Tag Manager it is a full featured enterprise product and available to us for free.
You will be prompted to add the Google Tag Manager code to your WordPress Header File. We will do this in a later step. For now you can close out of the window if it pops up.
Tags – are the equivalent of the HTML <tag> that are used for building the webpage. They are like little scripts of code that run when Triggered.
Triggers – This is an action that the visitor does that causes the tag to run or fire. Example a pageview is one type of trigger. Or clicking on a specific button on the page.
Variables – These are values that you set under variables for things like your domain name, your Facebook Pixel number, your Google Analytics ID etc, specific to your site.
Getting Started: Setup the Variables
First you will need to setup your Variables.
Click on Variables on the Menu on the Left side.
Then scroll down to User defined Variables and click the New button.
Click on the lego looking icon on the center of the screen.
Scroll down through the options till you get to Utilities Then Constant
Name the constant Domain, and enter your domain name in the field provided.
Add a second Constant variable.
Name: Google Analytics – Tracking ID
For the next variable, select Google Analytics Settings, rather than constant.
On the next screen, click the lego icon beside the Tracking ID.
Select the Google Analytics – Tracking ID variable we setup in the last step.
Keep the cookie domain as auto
Expand More Settings and Fields to Set
Start Typing AnonomizeIP in the first field and select the option when it appears.
Set the value to true
and click Save.
Setup the Triggers
Click on Triggers on the Menu on the Left side.
Since we are just doing a very basic setup with Google Analytics only, we will only need one Trigger, which will be a Page View
Click on New
Name your Trigger something like Page View or All Page Views
Click the double circle icon in the middle of the screen.
Select the first option Page View
Keep the default setting of All Page Views and click save.
Setup the Tags
Click on Tags on the Menu on the Left side.
Click on the New Tag button.
Give your tag a name like Google Analytics.
Click the tag icon on the middle of the screen and select the first option for Universal Google Analytics.
Click the drop-down for Google Analytics Settings and select the Google Analytics Settings variable.
Scroll down to the Triggering and click the double circles icon. Select the Page View trigger we just setup for all Page Views.
Install the Google Tag Manager Code
Since you will be using Google Tag Manager to manage your Google Analytics settings you will need to remove any previous Google Analytics settings or plugins so that you do not double up on your Google Analytics tracking. See this link for more details on removing any existing code and Confirming Google Analytics is installed.
On the top of the page, you will see GTM-XXXXXXX beside the Preview and Submit Buttons. Click on the GTM-XXXXXXX and the code you need to install will pop up, you will need to add this to your theme header file or to a Header/Footer Plugin.
See this post for instructions on adding code to your Theme header file here. This includes instruction on multiple methods.
Once the code is installed on your site, you will want to click the Preview Button.
Then open your website in a new tab on the same browser.
You will see the Google Tag Manager details popup on the bottom of your site to show that it is working and you should see the tag fire for a Page View from you opening the page.
If that is working as expected, go back to Google Tag Manager and Click the link Leave Preview Mode and click Ok to leave the preview mode.
Submit Changes in Google Tag Manager
Now you will need to submit the changes so that your Google Tag Manager changes Go Live on your site.
Click the Submit Button, give the version a name like Setting up Google Analytics, click the Publish button.
Once you have published your changes you are done.
Please let me know if you run into any trouble or have any questions in the comments below.