How to set up Google Analytics on a WordPress blog [2022]

I may get paid commission for purchases made after clicking a link in this post.

Share

Pin

Share

1.3K

Shares

Want to set up Google Analytics on your self hosted WordPress blog, but not sure how? In this tutorial I show you how to set up a Google Analytics account, where to put the tracking code on your website and how to check if Google Analytics is working on your blog.

Want to set up Google Analytics on your WordPress blog, but not sure how? In this tutorial I show you how to set up a Google Analytics account, where to put the tracking code on your website and how to check if Google Analytics is working on your blog. #GoogleAnalytics #WordPress #SelfHosted #GoogleAnalyticsforBloggers #Bloggers #Blogging #WordPressBlog #WordPressWebsite #ProductiveBlogging

Want to set up Google Analytics on your WordPress blog, but not sure how? In this tutorial I show you how to set up a Google Analytics account, where to put the tracking code on your website and how to check if Google Analytics is working on your blog. #GoogleAnalytics #WordPress #SelfHosted #GoogleAnalyticsforBloggers #Bloggers #Blogging #WordPressBlog #WordPressWebsite #ProductiveBlogging

 

What is Google Analytics?

Google Analytics is a fantastic free tool that can help you track and analyse your website traffic. It offers a whole host of statistics which show how your website is performing.

You can use it to track how many visitors and page views you are getting, how many views each individual blog post is getting, and which are your best (and worst) performing blog posts.

You can view this information over any time period you wish (today, last 30 days, last year etc.) and compare these figures to any other time period you choose (e.g. this month vs last month, this year vs last year).

You can also find out information about your readers and discover how your readers find and interact with your blog.

But before you can use this wonderful data, you first need to set up a Google Analytics account and put a small piece of tracking code onto your blog. This is what Google will use to collect all the information it needs in order to show you all the statistics about your blog that will enable you to track your progress and grow your blog!

How to set up Google Analytics on a WordPress blog

How to set up Google Analytics on a WordPress blog

 

2 versions of google analytics

There are currently TWO VERSIONS of Google Analytics. GA3 (AKA Universal Analytics or UA) and GA4. I recommend you set up BOTH. (See this post for my reasons why.)

Below I give tutorials for:

  • How to set up Google Analytics from scratch
  • How to set up a GA3 property (if you already have a GA4 property)

If you already have a GA3 property and would like to set up a GA4 property, head here for a full step-by-step Google Analytics 4 tutorial.

Once you have set up both a GA3 and GA4 property in Google Analytics, I advise you to use GA3 for the time being. (See this post for my reasons why.)

 

How to set up a Google Analytics account from scratch

To set up a Google Analytics account, go to google.com/analytics and click START FOR FREE.

You will be prompted to set up an account and a property. Simply give your account and property a name and hit CREATE. You will then be prompted to agree to Google Analytics Terms of Service and set your communications preferences. Google will then set up your Google Analytics property. (Typically you would set up one ‘property’ for each blog… so if you have more than one blog, you’ll need to set up a new property for each blog.)

By default, Google Analytics will create a Google Analytics 4 property. GA4 is the new version of Google Analytics. However, given that Google Analytics 4 is still quite new and most bloggers are still using Google Analytics 3 – AKA ‘Universal Analytics’ (which means most of the help and tutorials are for Universal Analytics), I recommend you create both a GA3 and GA4 property.

To do this head to ADMIN (the gear icon) in the bottom left hand corner of your newly created Google Analytics account. In the PROPERTY column, click the blue CREATE PROPERTY button.

Google Analytics Admin

Google Analytics Admin

You will be prompted to give your property a name. Type in the name of your website. Make sure the correct currency and time zone are selected and then select SHOW ADVANCED OPTIONS. Toggle CREATE A UNIVERSAL ANALYTICS PROPERTY on. Type in your website URL and select CREATE BOTH A GOOGLE ANALYTICS 4 AND A UNIVERSAL ANALYTICS PROPERTY. Click NEXT and then CREATE.

How to create a Universal Analytics property in Google Analytics 4

How to create a Universal Analytics property in Google Analytics 4

You will be automatically taken to the WEB STREAM DETAILS page where you can get your Google tracking code.

GA 4 Web Stream Details

GA 4 Web Stream Details

Simply scroll down to TAGGING INSTRUCTIONS and select GLOBAL SITE TAG (gtag.js). Copy the code and then paste it into the correct place on your website. (See below for 3 options for how to do this.)

 

How to set up a GA3 property (if you already have a GA4 property)

If you already have a GA4 property, it’s very easy to set up a GA3 property. Simply head to ADMIN (the gear icon) in the bottom left hand corner of your newly created Google Analytics account. In the PROPERTY column, click the blue CREATE PROPERTY button.

Google Analytics Admin

Google Analytics Admin

You will be prompted to give your property a name. Type in the name of your website. Make sure the correct currency and time zone are selected and then select SHOW ADVANCED OPTIONS. Toggle CREATE A UNIVERSAL ANALYTICS PROPERTY on. Type in your website URL and select CREATE A UNIVERSAL ANALYTICS PROPERTY ONLY. Click NEXT and then CREATE.

Google Analytics Add Universal Analytics Property Only

Google Analytics Add Universal Analytics Property Only

Simply copy the entire tracking code that begins <!– Global site tag (gtag.js) – Google Analytics –> and ends </script> and then paste it into the correct place on your website. (See below for 3 options for how to do this.)

Google Analytics Add Universal Analytics Property Only - add tracking code

Google Analytics Add Universal Analytics Property Only - add tracking code

Already got a Universal Analytics property and want to add a Google Analytics 4 property? Head here for a full tutorial >>> How to set up Google Analytics 4 (step by step with screengrabs)

 

How to toggle between your GA4 and universal analytics properties

You should now have two properties: a Google Analytics 4 property and a Universal Analytics property. To toggle between them, simply head to the top left hand corner of your Google Analytics account and click on the drop down menu immediately to the right of the word ANALYTICS.

How to toggle between GA4 and Universal Analytics properties in Google Analytics

How to toggle between GA4 and Universal Analytics properties in Google Analytics

Your Universal Analytics property will have the prefix UA. Your GA4 property will have no prefix. To select your GA4 property, simply click on the name of your GA4 property. To select your Universal Analytics property, click on the name of your UA property and then select the correct view (usually called ALL WEBSITE DATA, unless you have set up any custom views).

 

How to find your Google Analytics tracking code – GA4

If you already have your website set up as a GA4 property in Google Analytics, or if you want to find it again in the future, you can get your tracking code by going to ADMIN in the bottom left hand corner. In the PROPERTY column, select your website and then choose DATA STREAMS. You should see a screen which looks like this…

GA4 Data Streams

GA4 Data Streams

Select WEB and then click on the data stream (the bit that says your GA4 property name and number). You should see a screen which looks like this…

GA4 Web Stream Details

GA4 Web Stream Details

Simply scroll down to TAGGING INSTRUCTIONS and select GLOBAL SITE TAG (gtag.js). Copy the code and then paste it into the correct place on your website. (See below for 3 options for how to do this.)

 

How to find your Google Analytics tracking code – Universal Analytics

If you already have your website set up as a Universal Analytics property in Google Analytics, or if you want to find it again in the future, you can get your tracking code by going to ADMIN in the bottom left hand corner. In the PROPERTY column, select your website and then choose TRACKING INFO => TRACKING CODE. Copy the tracking code.

How to set up a Google Analytics accountHow to set up a Google Analytics account

 

How to set up a Google Analytics accountHow to set up a Google Analytics account

 

Where to put the tracking code on your website

There are basically 3 ways of adding your Google Analytics tracking code to your WordPress blog: you can add it directly into your code (don’t do this unless you know what you are doing!), you can use a plugin, or you can use your theme settings (this is by far the easiest way!).

Let’s look at each of these in turn…

 

1. Using your theme settings

Many themes will have a place where you can put your Google Analytics tracking code. Check your theme documentation to see if this is possible for you. If it is, it’s by far the easiest way. (If you are not sure, ask your theme developer or ask in your theme’s support group.)

 

2. Placing your tracking code directly into your code

DO NOT DO THIS UNLESS YOU KNOW WHAT YOU ARE DOING! If you do something wrong here, you can crash your entire site – if you decide to use this method, proceed with caution and make sure you do a backup of your site first.

Log in to your WordPress dashboard and navigate to APPEARANCE => EDITOR. Now click the header.php file on the right-hand side below the TEMPLATES section. Paste the tracking code you copied from your Google Analytics profile just before the closing </head> tag. Then click UPDATE FILE.

 

3. Using a plugin

If you are not confident in placing code into your theme files and you do not have the option to add the code via your theme settings, then the best way for you to place your Google Analytics tracking code onto your website is using a plugin. There are many plugins that you can use to do this, but one that seems particularly good is the Monster Insights plugin. You can find details on how to do this on the Monster Insights website => How to connect Monster Insights to Google Analytics.

I have not used this plugin myself as I was able to use my theme settings, so I cannot personally recommend it, but from a quick bit of research into this type of plugin, this one seemed the best to me – there is both a free version and a premium version.

Monster Insights for Google AnalyticsMonster Insights for Google Analytics

 

Please note, it’s really important that you only have the Google Analytics tracking code added ONCE to your website. If you have it more than once on your website, you will get very bizarre and inaccurate statistics. So, before you use one of these methods it’s important to check if it is on there already. If it is, you don’t need to do it again!

 

How to check if your Google Analytics is working

Once you have installed the tracking code on your site, check to see if it is working. Go to Google Analytics, select your Universal Analytics property, and go to REAL-TIME => OVERVIEW in the menu on the left. If the tracking code is correctly installed, you will be able to see visitors to your website in real time.

Universal Analytics Real Time Overview

Universal Analytics Real Time Overview

To check your Google Analytics 4 property is working correctly, select your GA4 property from the drop down menu, and go to REPORTS => REAL-TIME. If everything is working correctly, you should see real-time data appearing here too.

GA4 Realtime Report

GA4 Realtime Report

Congratulations on setting up Google Analytics for your website! Now it’s time to discover how to actually use Google Analytics in my Beginner’s Guide to Google Analytics.

 

More on this topic…

 

Don’t miss a thing!

Follow me on TwitterFacebook and Instagram. Or why not subscribe to Productive Blogging and get blogging and productivity tips straight to your inbox every week?

 

Pin this post to read later

Want to set up Google Analytics on your WordPress blog, but not sure how? In this tutorial I show you how to set up a Google Analytics account, where to put the tracking code on your website and how to check if Google Analytics is working on your blog. #GoogleAnalytics #WordPress #SelfHosted #GoogleAnalyticsforBloggers #Bloggers #Blogging #WordPressBlog #WordPressWebsite #ProductiveBlogging

Want to set up Google Analytics on your WordPress blog, but not sure how? In this tutorial I show you how to set up a Google Analytics account, where to put the tracking code on your website and how to check if Google Analytics is working on your blog. #GoogleAnalytics #WordPress #SelfHosted #GoogleAnalyticsforBloggers #Bloggers #Blogging #WordPressBlog #WordPressWebsite #ProductiveBlogging

Share

Pin

Share

1.3K

Shares