How to Add Google Analytics to WordPress: A Beginner's Guide
By Tommy Griffith • Last Updated: October 16, 2020
A simple guide on how to correctly add Google Analytics to your WordPress site by using Google Tag Manager. Perfect for beginners and non-technical people.
There are two main reasons why you’d want to install Google Analytics tracking onto a WordPress site using Google Tag Manager:
You haven’t installed the Google Analytics tool yet and you’re doing it for the first time;
You HAVE installed it (maybe through a Google Analytics plugin like the Monsterinsights plugin or the WordPress plugin Yoast), but your Google Analytics dashboard isn’t showing any data and it looks like the installation went wrong;
In this blog post, I’ll go through the exact step by step process you need to follow to install Google Analytics onto a WordPress site / WordPress theme using Google Tag Manager.
Sidenote: if you’re not using WordPress, check out our guides on how to add Google Analytics to Shopify or Squarespace.
Let’s get going.
Adding Google Analytics to a WordPress website will take about 15 to 30 minutes, and here’s the high-level overview of how to get this done:
The goal: To add Google Analytics to a site using Google Tag Manager and verify that it’s working properly.
The ideal outcome: Google Analytics is properly installed and added to your site without any technical issues.
The importance of this action: Google Analytics is the most popular tool to measure traffic on your website and gather data on your visitors. Once you’ve done this, you’ll have access to thousands of metrics like how much traffic you’re getting and how your visitors are behaving on your website.
Where this is done: This will be done in Google Tag Manager and Google Analytics.
When this is done: You only have to do this once and, if you haven’t done it yet, you should do it ASAP.
Who does this: Whoever is responsible for managing your website or your Analytics.
Get This Entire Walkthrough and All the Resources in This Post
Set Up Your Google Analytics Account
If you haven’t already done this, you will first have to sign up for Google Analytics:
Go to Google Analytics. If you haven’t signed up for an account yet, you’ll see a wizard that says “Create an account, start here”. Click that button.
Enter your account name. In my case, this was “A Site About Emojis”.
Enter your website name. In my example, this was also “A Site About Emojis”.
For a lot of people, the account name and the website name will be the same. This might differ if, for example, you’re setting up a company and then that company has multiple domains underneath. In that case, you might have an account name and then multiple website names underneath.
Enter your website URL. In this example, this was “http://www.asiteaboutemojis.com”.
Enter your industry category. This doesn’t matter too much, it’s basically just more information for Google.
Set your time zone.
Underneath all the fields you have to fill out, you will see a few options Google checks by default. I usually uncheck them, but it probably doesn’t matter all that much either way.
Click “Get tracking ID”.
Accept the “Terms and Conditions”.
You will now reach the section of Google Analytics where they give you your Google Analytics tracking code. If you are setting up the site normally, without Google Tag Manager, you might take this and paste it into theof one of your site templates in WordPress.
However, there’s a simpler way to do this, I’m going to show you how to do this through Google Tag Manager. So, instead of copying the Google Analytics code, copy the “Tracking ID” at the top of the screen – take that and paste it into a note.
Add the Google Analytics Tag to Google Tag Manager
Now that you’ve set up Google Analytics and copied your Google Analytics ID, head over to Google Tag Manager. Remember, if you haven’t set this up yet, you can check out our Google Tag Manager tutorial.
To properly setup Google Analytics using Google Tag Manager, you will have to go through three main steps:
Creating the Google Analytics tag and tracking ID variable in Google Tag Manager;
Adding the Google Analytics Universal tag and triggering it in the right pages;
Submitting all of the changes you have made to your Google Tag Manager container;
So, here it goes:
Creating the Google Analytics Tag and the Tracking ID Variable in Google Tag Manager
Log into Google Tag Manager.
On the left hand side, click “Tags”.
Name your tag. You want to think about your naming convention—it will make it much more straightforward and easier to navigate Google Tag Manager in the future, especially if you start to add a lot of tags to it. So, my advice for you is to pick a really clear, easy to follow naming convention.
In my example, I used the convention “GA” (for Google Analytics) – so my tag’s name was “GA_TrackingCode”.
Click the little pencil under “Tag Configuration”.
Click “Universal Analytics”. This is the current version of Google Analytics, so 9 times out of 10 you’re going to be using this one.
Click on the “Google Analytics Settings” drop-down menu → “New Variable”.
In the “Tracking ID” field, paste the Tracking ID you saved to a note earlier.
Click outside of the “Variable Configuration” box.
Give this variable a name. In my case, this was “GA Tracking Code”.
Creating the Google Tag Manager Trigger for your Tag
Click the little pencil under “Triggering”.
Click the “+” sign in the top right hand corner.
Click the little pencil under “Trigger Configuration” again.
Click “Page View”.
Leave “All Page Views” checked.
Name the trigger. In my case, this was “All Page Views”.
Click “Save” again.
Publishing your Google Tag Manager Container
Go back to your Google Tag Manager Workspace.
(Optional) If you have multiple changes you have made to Google Tag Manager, you can sort by “Last Edited” to see the Google Analytics one.
In the upper side of the screen, you will also see the number of workspace changes. In my case, it shows “2” because there were 2 workspace changes that had not been submitted yet.
Add a Version Name and a Version Description. I usually choose to be quite descriptive here so that in the future, if someone else is working on this, they will know what was changed. In my case, the version name here was “Adding Google Analytics”, and the Version Description was “This update contains Google Analytics installation”.
Verify the Google Analytics Installation
Now that you have set up Google Analytics and added it to your Google Tag Manager, you will want to make sure it’s actually working.
You will see Google Analytics and Google Tag Manager there.
Alternatively, you can also verify your Google Analytics installation using the following method:
Go to your website in one Chrome tab.
Open Google Analytics in a new tab.
On the left hand side, under “Reports”, click “Real Time” → “Overview”.
You should be able to see at least your session showing up on Google Analytics.
Creating Google Analytics Views
Once you have properly installed Google Analytics and checked that it’s working, there are some basic good practices you should setup straight away to make sure you future-proof your account.
One of them is setting up multiple Google Analytics Views.
If you go to your Google Analytics Admin, you will see three different columns there: your Account, your Property, and your View.
By default, Google Analytics will set up only 1 view named “All Website Data”. Having only this view will still allow you to take advantage of everything Google Analytics has to offer. However, this is not a good practice since you might start getting more advanced with Google Analytics in the future and start adding filters or other data processing settings to this view. In that case, you will not have a way to recover the unprocessed Google Analytics data.
Setting up at least these 3 different views will allow you to safely apply and test new settings on your view while minimizing any data-loss risks:
Main View – where you do the majority of your analysis, your day to day stuff. This should be working flawlessly, without any kind of problems.
a) You can just rename the Google Analytics default “All Website Data” for this purpose.
b) To rename it, click on it → “View Settings”.
c) Under “View Name”, enter “Main View” – this will help you keep things clean and organized in your Google Analytics.
d) Click “Save”.
Staging view – your testing ground. This is where you run experiments, where you try out new things. You can mess this one up because it’s a staging view, so it’s to be used to test out new settings, filters, or any other configurations before moving them to the “Main View” (once you know they are working as intended)
a) Under the “View” column in your Google Analytics Admin Panel, click “All Website Data”.
b) Click “View Settings”.
c) Click “Copy View” (top right hand side of the screen).
If you’re ready to take your tracking to the next level, be sure to check out the ClickMinded Google Analytics Training Course.
Double Conversions With Laser-Focused Google Analytics
Get the 2020 Ultimate Guide to Perfect Google Analytics Tracking sent to your inbox.
Analytics Mini-Course: Grab the exact walkthrough you need to setup a Google Analytics account with perfect tracking.
Analytics Masterclass: Learn how to massively increase your ROI with Perfect Google Analytics Tracking.
8,702 companies use ClickMinded to learn Google Analytics and massively increase conversions.
Massively grow any business with digital marketing SOPs.
Thank you for being a part of the ClickMinded family!
Tommy Griffith has been doing search engine optimization for almost 10 years. He was previously managing SEO at PayPal and Airbnb.
He feels weird writing about himself in the third person, but admits that it sounds slightly more epic.