How to Add Google Tag Manager to WordPress

      Comments Off on How to Add Google Tag Manager to WordPress
How to Add Google Tag Manager to WordPress
(Last Updated On: )

Perhaps one of the most important things you can do for your website is ensuring you are tracking your Google Analytics. It is one of the basic components that I encourage everyone to do. I just learned about a better way to add Google Analytics to your site. It is the Google Tag Manager (GTM). It is a recommendation I picked up while reading Google Analytics Breakthrough. The Google Tag Manager will allow you to separate the management of marketing and tracking tags from the operation of your website. You will also have the ability to test out tags before you put them into operation. Let me show you how to install Google Tag Manager on your WordPress site and add the Google Analytics tag. Even if you do not run a WordPress site, you will benefit from adding GTM. Contact me if you need assistance.

Because I was already running Google Analytics on my site, it took me 5 major steps to add the Google Tag Manager. If you are not running Google Analytics, you will be able to do it in four.

1. Setting Up Google Tag Manager

The first thing you need to do is create your Google Tag Manager account.

  1. Go to Tagmanager.Google.Com and log in. If you do not have an account, you will first need to create one.Go to Google Tag Manager and create an account
  2. Click on the Create Account option.
  3. Enter the Account Name and click on the Continue button.
  4. Enter your website address, click on the Web button, and then click on the Create button.
  5. Agree to the Terms of Service.

At this time, you will have the code that you can add to your website. If you have a WordPress site, you have this option but I recommending going to step 2. If you do not have a WordPress site, you could now add the code for your particular site and then move to step 4.

2. Setting Up Google Tag Manager for WordPress

The next step is to set up the Google Tag Manager for WordPress plug-in and add the Google Tag Manager ID.

  1. Install the Google Tag Manager for WordPress plugin as you would for any WordPress plug-in and activate it. Search for “Google Tag Manager for WordPress.” It is officially called the DuracellTomi’s Google Tag Manager for WordPress.add Google Tag Manager for WordPress
  2. Click on the Setting link for this plugin.
  3. Return to Tagmanager.Google.Com and copy the Container ID for your site.Copy the Google Tag Manager ID
  4. Return to the plug-in and paste the Container ID in the field provided.Paste GTM ID and save
  5. Click on the Custom radio button. NOTE: you have other options, but this is the method I recommend.
  6. Click on the Save Changes button.

There are many settings that you can change for this plugin that I will discuss in another post. The next step is to add the code to your site.

3. Adding the Code to the Page

This would be something that you ask your web developer to do if you do not have access to your WordPress site. Here are the steps I followed:

  1. If you are not there, go to the Google Tag Manager for WordPress plugin. Navigate to the General tab.
  2. Copy the line of code that looks like this <?php if ( function_exists( ‘gtm4wp_the_gtm_tag’ ) ) { gtm4wp_the_gtm_tag(); } ?>Copy the container code
  3. For a WordPress site, select the Appearance menu item from the left hand menu and then select Editor.
  4. Select the Theme Header from the pages listed on the right-hand menu.
  5. Paste the code just above the </head> tag. Note: the plugin instructions say insert after the <BODY> tag, but I found it to be better just before the </HEAD> tag.Paste the code above the </head> tag
  6. Once done, click on the Update File button.
  7. Check your site using the Google Tag Assistant (described below).

If you are using a different blogging system, your experiences will vary from setting it up for WordPress. I would be happy to assist.

If you set up everything correctly, you should see your Google Tag Manager listed in the Google Tag Assistant.

4. Adding the Google Analytics Tag to GTM

The next step is to add Google Analytics to GTM. Here are the steps that will help you do this smoothly:

  1. Go to GTM at Tagmanager.Google.Com.
  2. Open the account where you want to add the Google Analytics Tag.
  3. Click on the Add a New Tag link.Click on Add a New Tag
  4. Give your tag a name.
  5. Click on Tag Configuration.
  6. Select Universal Analytics.
  7. Under Google Analytics Settings, select New Variable.
  8. Give the variable a name. I personally used “GA Variable”.
  9. You will now need to put in your Google Analytics ID number. You can find that information here:
    1. Open another tab and go to your Google Analytics (https://analytics.google.com/).
    2. Ensure that you are on the correct account.
    3. Select the Admin option from the left-hand menu.
    4. Select Property Settings under the Property column.
    5. Copy the Tracking ID.
  10. Return to GTM and paste it into the Tracking ID field. Click on Save Button.
  11. The next thing to do is set up a trigger, so click on the Triggering box.
  12. Click on All Pages. When done, it should look like this. Completed Google Tag Manager tag
  13. Click on the Save button. It should then return you to the main GTM page. You should see two workplace changes: Google Analytics variable and tag.
  14. Optional: You can preview the changes on your site if you wish by selecting the Preview button. To leave the preview mode, click on the Leave Preview Mode link.Location of the Leave Preview link
  15. To activate your changes, click on the Submit button.
  16. Give your changes a name. Provide a description if you wish. I normally use the name of my site and date.
  17. Click on the Publish button to make your changes final. Fortunately, you can roll back changes if you wish.
  18. Check your site using the Google Tag Assistant (described below).

If you set up everything correctly, you should see your Google Tag Manager and Google Analytics listed in the Google Tag Assistant. If you already had Google Analytics set up, you may see two Google Analytics tags.

5. Remove Old Plugins and Tags

The last step is to remove old plugins and tags from your WordPress site. I personally had a Google Analytics plugin called Google Analytics Dashboard for WP that I was using.

To carry out this last step, I followed the following steps:

  1. Navigate to your list of plugins for your WordPress site.
  2. Click on the Deactivate link for the appropriate plugin. I recommend ensuring you have a working tag in GTM before disabling the plugin.
  3. Once the plugin is deactivated, click on the Delete link for the plugin.Deactivate and delete old links
  4. With the plugin disabled and removed, check your site using the Google Tag Assistant (described below).

If you set up everything correctly, you should see your Google Tag Manager and Google Analytics listed in the Google Tag Assistant.

Google Tag Assistant

The Google Tag Assistant is a Google Chrome browser plugin that lets you see if you have Google Tracking scripts running properly on your site.

Installing Google Tag Assistant

It is quite easy to install the Google Tag Assistant on the Chrome browser, just go to this link and click install.

Running Google Tag Assistant

To run the Google Tag Assistant, first, open a new browser tab. Then click on the Google Tag Assistant tool and click on the Enable button. Next launch your website in this open tab.Enable the Google Tag Assistant

When your site opens, you will see the Google Assistant Tag icon reflect the number of tags found by showing a number. In our case, we should see the number “2” because we are expecting a Google Tag Manager and Google Analytics tag.Google Tag Assistant tag status

To verify the status of tags, click on the Google Tag Assistant tool. You should see a list of tags and their status. You can discover more by clicking on the tag name.

If you need assistance getting this set up, please contact me. Using the GTM to manage your tags is the preferred method. If you are not doing this, I recommend making the change. You can quickly see if you are using GTM by running the Google Tag Assistant and checking your site.

Additional Reading