How to set up Google Analytics on WordPress with Google Tag Manager

, Posted by Adrian Kingwell in Blog, Phil's posts, Web Analytics

Phil Craig gives us a cookery lesson with a difference: how to deploy GA tags on a WordPress website via GTM.

Get your chef’s hat on, as I am about to teach you how to bake page-level tracking tags onto every page of your delicious WordPress site using a simple plugin and some fresh Google Tag Manager.

Ok, I don’t think this recipe is going to turn you into Jamie Oliver, but it might teach you what people are consuming on your website. Lovely jubberly.


  • 1 whole WordPress site (live)
  • 1 Google Tag Manager plugin for WordPress
  • 1 fresh Google Tag Manager container ID
  • 1 Google Analytics account tracking ID


You may have a WordPress site already set up, but you may not have a Google Tag Manager (GTM) container set up and installed. So let’s look at that first.

Set up Google Tag Manager container

  1. Go to https://tagmanager.google.com
  2. Create a GTM account.
  3. Copy the container ID

Using a GTM plugin in WordPress means you won’t need anything else other than the container ID. Easy.

Set up WordPress plugin

  1. Click on WordPress Admin → Plugins (in the left hand navigation bar)
  2. Click on New
  3. Use the search bar to find all plugins that relate to “Google Tag Manager”.
  4. Choose your plugin. Find one that looks good, based on the reviews. At the time of writing “Google Tag Manager for WordPress” by DuracellTomi has the best ratings as well as over 50,000 active installs. I’d say this is the best bet. It has some cool features that means you can enable data layer events without any further implementation and with no need for JavaScript knowledge. If you don’t know what a data layer is, check out my blog article on data layers.
  5. Install the plugin
  6. Activate the plugin

Now you have installed your plugin and have your GTM container ID, you are nearly there. You just need to put the ID in the right place to communicate between the two vendors. Depending on the plugin you have installed, you will put the ID in the general settings or under the Google Tag Manager settings. If you hadn’t guessed it already, both of these options will be under Settings in the left hand nav. There will be a box for you to put your code ID into.

That is all you will need to do within WordPress to get the simplest of GTM set-ups. If you want to explore other built in functions, please do, but they will require a more in-depth knowledge of GTM.

Create tags in GA

  1. Log into your Google Analytics account. If you do not have an account, create one at analytics.google.com.
  2. Click on the Admin → Property → Property Settings. Here you should find the UA code (Tracking ID) to link Google Tag Manager to Google Analytics.
  3. Copy the UA code.

Add tags to GTM

  1. Go to tagmanager.google.com and click on the container you created.
  2. Look at the left hand navigation and click Tags
  3. Click on New to create a new tag

You should now see a similar screen to the one below:

New Google Tag Creation with Google Analytics and GTM

  1. Name the new tag ‘Universal Analytics – All Pages’
  2. Choose Product → Google Analytics
  3. Choose Tag Type → Universal Analytics (Universal Analytics is a more modern version of ‘Classic Google Analytics’ with added tracking benefits.)
  4. Now paste the UA code under ‘Tracking ID’ box in the ‘Configure Tag’ section. *
  5. Choose Track Type → Pageview
  6. Click Fire On → All Pages
  7. Click Create Tag   Top Tip: if you are going to create lots of tags, set up your Tracking ID as a ‘constant’.
  8. Go to Variables → New → Constant
  9. Paste your UA code into the box
  10. Name your variable “UA code”

When you want to use it under your tracking ID section in tag setup, simply type in “UA code” and you will have it at your disposal.

Test it’s working

GTM is pretty great for testing. Within the GTM interface you will see the Publish button in the top right hand corner. Click Publish → Preview.

Google Tag Manager Testing with Google Analytics

Now go to your website and you should see something like this:

Google Tag Manager Testing View used with Google Analytics

This is GTM’s built-in debugging tool. As you can see above, tags that have loaded on this page are clearly displayed.

If your tag has loaded on this page (try a few others for safety), then you are ready to publish.

  1. Go back to the GTM interface and leave preview mode
  2. Click Publish
  3. Click Publish Now to push all changes live
  4. Now return to your site and refresh the page

To check if both GTM and therefore GA have loaded correctly, I recommend downloading the Chrome extension James or Tag Assistant. This will make it easy to see what has been loaded on your page without going into the console.

James Extension used with Google Analytics

Once you’ve installed one or both of those extensions, click on either of them. If you have Google Tag Manager and Universal Analytics displayed (similar to above) then you are all set and ready to serve your guests.

Over the next few days monitor your data collection in Google Analytics to see if there are any anomalies.

Final thought: so, why did we not use a GA plugin?

Good question. There are endless possibilities with GTM, but this is just the basic set up. The more experience you get  with the tool, the more detailed specifics you can track. If you want to capture submits on contact us forms or create custom dimensions to see what length of blog performs best, GTM will be able to do this. Standard GA tracking will not (without a lot of custom coding).

So go on, give it try it yourself. You might like it.