How to set up Google Analytics on WordPress with Google Tag Manager, Posted by Blog, Phil's posts, Web Analytics in
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
- Go to https://tagmanager.google.com
- Create a GTM account.
- 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
- Click on WordPress Admin → Plugins (in the left hand navigation bar)
- Click on New
- Use the search bar to find all plugins that relate to “Google Tag Manager”.
- Install the plugin
- 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
- Log into your Google Analytics account. If you do not have an account, create one at analytics.google.com.
- Click on the Admin → Property → Property Settings. Here you should find the UA code (Tracking ID) to link Google Tag Manager to Google Analytics.
- Copy the UA code.
Add tags to GTM
- Go to tagmanager.google.com and click on the container you created.
- Look at the left hand navigation and click Tags
- Click on New to create a new tag
You should now see a similar screen to the one below:
- Name the new tag ‘Universal Analytics – All Pages’
- Choose Product → Google Analytics
- Choose Tag Type → Universal Analytics (Universal Analytics is a more modern version of ‘Classic Google Analytics’ with added tracking benefits.)
- Now paste the UA code under ‘Tracking ID’ box in the ‘Configure Tag’ section. *
- Choose Track Type → Pageview
- Click Fire On → All Pages
- Click Create Tag Top Tip: if you are going to create lots of tags, set up your Tracking ID as a ‘constant’.
- Go to Variables → New → Constant
- Paste your UA code into the box
- 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.
Now go to your website and you should see something like this:
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.
- Go back to the GTM interface and leave preview mode
- Click Publish
- Click Publish Now to push all changes live
- 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.
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.