Are you looking to install Google Tag Manager on Wordpress? You landed on the right place! By following this guide you would be able to:
- Create a Google Tag Manager account
- Install Google Tag Manager on Wordpress
- Connect Google Analytics with Google Tag Manager
- Debug & Preview Google Universal Analytics tag
- Install Google Tag Assistant to verify reporting
- exclude Wordpress internal traffic to view accurate data
If you are new to Google Tag Manager I recommend you learn what Google Tag Manager can do, so you can better utilize the tool.
Without wasting your precious time, let's move on to set up Google Tag Manager on your Wordpress site.
1). Create Google Tag Manager Account
Step1: Sign in to Google Tag Manager account. If you are new to tag manager you will be directed to create a new account. The best practice is to enter your company name in the account name field.
Step2: Click continue button and enter container name and select where to use this container. In this case, the best practice is to write your website url as container name, select web and click create.
Step3: Once you accept the tag manager services agreement, a pop up window will appear displaying the container code snippets.
keep this page as it is and open your Wordpress dashboard in a new tab.
2). Install Google Tag Manager on Wordpress
Once you create a your Google Tag Manager account, you have two options to add GTM code on your Wordpress site. The first method is by copying the Tag Manager container code and pasting into your Wordpress header.php file. The second method is by installing the Google Tag Manager Wordpress plugin.
Below I have explained both methods. If your Wordpress dashboard is overloaded with plugins follow the first method otherwise move to the second method.
i). Add Goole Tag Manager Code to Wordpress Manually
Step1: login to your Wordpress dashboard and navigate to Appearance >> Editor.
Look for header.php file from the list of files on the right side.
Now, go to your tag manger account and copy the first tag manager script and paste it just before the </head> tag and paste the second snippet just after the opening body tag<body>.
Step2: Click on the update file button and don’t do anything else here.
Once you are done, verify installation by clicking here.
ii). Install Google Tag Manager on Wordpress via Plugin
Let’s get started by installing Duracelltomi’s Google Tag Manager plugin. Go to your WordPress dashboard Plugins > Add New and search for DuracellTomi’s Google Tag Manager.
You will see this
You can also install it manually by downloading it from WordPress site and adding the file into your plugins folder.
Once the plugin is installed, activate it to start using GTM. But wait, that’s not all. Now, you will need to connect this plug-in with GTM and Google Analytics.
From the left menu, go to Settings > Google Tag Manager and you should see something like this:
Now, go to your GTM container and copy the Google Tag Manager id. If you don't know where is GTM id, see the image below
Copy this Google Tag Manager ID and paste into the DuracellTomi's plugin field.
Now paste this code into the DuracellTomi’s ‘Google Tag Manager ID’ field and click save changes.
By now you have successfully integrated Google Tag Manager on WordPress using DuracellTomi’s plugin. Are you done? What’s next?
3). Connecting Google Analytics with Tag Manager
Google Tag Manager Wordpress tutorial is not just about installing a plugin but also getting reports in google analytics.
To view your website reports, you will need to connect Google Analytics account with tag manager. Let’s see what reports are we capable of getting in the Google Analytics account.
If you are new to GA, please read how to Get started with Analytics. I am assuming that you already have a Google Analytics account. Follow the steps below for creating a new pageview tag in GTM.
1. Inside your container create a new tag.
2. Enter the tag name as GA Pageview.
3. From the pop up window, click on the Tag Configuration and select Universal Analytics.
4. Enter the Google Analytics ‘Property ID’ (if you don’t know where it is, read this).
5. Choose the track type as ‘Page View’ and click continue.
6. Next, click on the trigger section and select all pages trigger. This is the only pre-built trigger in GTM.
Your final pageview tag should be like
7. Finally, click on the save button.
4). Debug & Preview Google Universal Analytics tag
To verify if you have successfully added the page view tag, you will have to preview and debug your workspace. Once you save the pageview tag, you will be taken to default workspace window. Before publishing your changes in the workspace, it is always recommended to test changes.
Click on the preview button.
Open your website in a new tab. The preview mode will show the list of tags fired on your site.
If your tag is fired successfully, it’s time to publish the tag.
Get back to tag manager account and click on the leave preview mode button.
Next, click on the publish button to set the settings live.
This simple tag will allow you to receive data in google analytics such as the number of users visiting your site, pages they are viewing, their time on site, bounce rate and much more.
5). Install Google Tag Assistant to verify reporting
The last thing is to verify if Google Analytics & Google Tag Manager tags are installed correctly. For this, we will install Google Tag Assistant extension in your browser. Once installed, click on the tag icon and enable it. Now reload your site and click on the tag assistant icon, if you have properly followed the steps you should see tag manager icon and analytics icon as shown in the picture below:
Sometimes, Google Tag Assistant report incorrect errors. The other way to verify is by sending test traffic to Google Analytics or check the real time traffic.
6). Exclude Wordpress Internal Traffic
You would never want to see how many times you visit your own blog or how many visits from within your company. To make your Google Analytics data accurate you will have to exclude all the hits coming from your Wordpress admin. This should be necessary step for every Wordpress site.
Learn to exclude Wordpress internal traffic
Bonus guide for every Google Analytics user
If you have made to this point and had success with the above guide, I would recommend you to follow one more essential step. Your Google Analytics account is precious, because it contains your website traffic data. If you don't know the best way to use Google Analytics then you might end up with inaccurate reports.
Follow the below article to setup goals, excluding spam traffic, filtering bots and creating multiple views for better reporting.