Installing Google Tag Manager in Wordpress

Installing Google Tag Manager in Wordpress

If you are using a Wordpress website, but need some assistance for integrating Google Tag Manager (GTM) into it, you’ve come to the right place.

Google Tag Manager is a popular Tag Management System (TMS), whose core purpose is to enable dynamic insertion of tags into your website. In the long haul, going through this process would save you from future exasperation and some hefty upgrading measures. I say that because updating tags and maintaining them throughout various platforms like Google AdWords tags, Google Analytics tags, as well as a bunch of third party tags management systems, would either take up a lot of your time or would require a developer’s expertise to constantly update the underlying site code.

 

Using GTM would enable you to create synchronization among all utilities you are using for tagging and is simple enough to comprehend and deploy, even for a newbie himself.

So if you are just getting started, here is a basic beginners’ guide to installing Google Tag Manager in Wordpress using DuracellTomi’s plugin.


First things first: You should know the difference between wordpress.org and wordpress.com

There are at least two ways of installing google tag manager in wordpress. First way is by copying and pasting tag manager container code to your wordpress header.php file. The second method is by installing the google tag manager wordpress plugin.


I am covering both the methods for your ease.

1). Google Tag Manager for Wordpress

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.

create a new account

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.

set the container name

Step3: Once you accept the tag manager services agreement, a pop up window will appear displaying the container code snippets.

tag manager container code

Step4: login to your wordpress dashboard and navigate to Appearance >> Editor.

wordpress dashboard

 

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>.

adding google tag manager in wordpress

Step5: Click on the update file button and don’t do anything else here.  

Once you are done, verify installation by clicking here.

 

2). Google Tag Manager Wordpress 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

Duracelltomi wordpress plugin

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:

Google Tag Manager Tracking Id

Let’s move to Google Tag Manager now. Open a new tab in your browser and type in "tagmanager.google.com" and press “Enter”. Sign in with your Gmail account details; If you don’t have a Gmail account then sign up for it.

Note: Remove any other google analytics script that you have inserted on your site for proper implementation.


Once you have logged into GTM you will have to create an account and a container for your site. The initial account structure will be something like this. 

Add account tag manager

Let’s create our first account by filling the proper details. Type a name for your account in the ‘account name’ field. You can enter your website’s name or your company’s name. Enable the checkbox ‘sharing data anonymously with Google and others’ and click continue.

Next enter a container name and select ‘Web’ for inserting the container into your Wordpress site. Click create and a pop up window will open showing GTM terms and conditions. Click yes and you will see a container snippet showing Google Tag Manager code and then click “ok” to terminate the container.

 

Read Also: Exclude All Wordpress Internal Traffic from Google Universal Analytics

 

Where to put Google Tag Manager code?

Copy the Google Tag Manager tracking ID that was generated after we created the container. You can find this tracking ID on the top navigation bar as shown in the picture below, or in the code snippet container which was popped up after accepting the GTM terms and conditions.

Google Tag Manager Container

The tracking ID is located on the top navigation bar and is similar to  GTM-XXXXXX. Copy this code and go to your Wordpress dashboard.


Now paste this code into the DuracellTomi’s ‘Google Tag Manager ID’ field and click save changes.

Google Tag Manage ID

By now you have successfully integrated google tag manager WordPress using DuracellTomi’s plugin. Are you done? What’s next?

 

Adding Google Analytics With Wordpress

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.

create new tag

2. Enter the tag name as GA Pageview.

enter tag name

3. From the pop up window, click on the Tag Configuration and select Universal Analytics.

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. 

configure pageview tag

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

pageview tag preview

7. Finally, click on the save button.

 

Verify Pageview Tag Setup

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 publish drop down menu and click on the preview button.

Open a new tab on your browser and open your site in which you have just installed tag manager.
The preview mode will show the list of fired tags on your site.

preview mode

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.

cancel preview mode

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.

 

Verify Google Tag Manager Wordpress Installation


The last thing is to verify if we have added google tag manager Wordpress plugin successfully. For this, we will install Google Tag Assistant extension in chrome 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:

Google Tag Assistant 

The blue color in analytics icon indicates that there are some minor issues with GA code while tag manager is working properly. Google tag assistant help provides more information about queries related to tag assistant. Your task is to find out how to resolve the blue color analytics icon issue.

The other way to verify is to open google analytics reporting tab and check Real Time reports. You should see the number of visitors on your site and if you don’t see any, open your site in a new tab and check again.

So far we have successfully completed Google Tag Manager Wordpress installation and started collecting data in Google analytics. I hope you also succeeded in getting the things done and if you are missing out on something, please let me know. Good Luck! :)

 

PS. This is the very basic analytics setup which allows you to start seeing pageviews. From here you can do a few things:

Create Goals

See which traffic sources are working

Exclude Wordpress Internal Traffic From Google Universal Analytics


Once you've gotten a feel of it, you may want to explore tracking revenue or maybe even talk to us to figure out a more customized plan for your needs.

M. Jhone

I am an Analytics Specialist focusing on nitty and gritty of google analytics and google tag manager. I have been working with digital analytics for a year, so try to write about topics that focus on fundamentals of using the tools.

I am a keen follower of technology and then last Micorsoft supporter in a sea of Apple fanboys at MarketLytics. May I stay steadfast in my beliefs! :)