How to Add Google Analytics to WordPress – It’s Easier Than You Think!

Are you looking for an easy to follow guide that shows you How to Add Google Analytics to WordPress?  Then you’ve definitely landed in the right place.   Google has over two thirds of the traffic online, so if you want to know how to ensure your blog fits your target audience, or even help understanding who is visiting your site, you need to have it installed on your site.

Business owners and Blog owners need to know who their audience is, to ensure that they content appeals to them, so they stay on your site and read your content, sign up to your email list, click on your affiliate links, whichever reason you are targeting on your site.

Going in blind, will make it a much harder job for you…

But the end of this guide, you’ll know a little more about Google Analytics, including it’s benefits, and ultimately how to add Google Analytics to WordPress in an easy to understand step-by-step process.  Let’s get started, shall we?

Table of Contents

Before we get into the process of installing Google Analytics on your WordPress site, let me explain why Google Analytics is really helpful to website owners…

Why Is Google Analytics Helpful to Website Owners?

Anyone not using Google Analytics on their blog or website is missing out on so much valuable information. Imagine having a store on the high street, you will know who is interested in your brand or products by those coming into the store and if they buy something you know you are doing something right. 

But if you have a website and you are not tracking what your visitors are doing and they are not buying anything – how do you know what you need to change??

That is why you need to know who is visiting your site, what they are doing on your site, when do most visitors visit your site and how they are accessing your website. What is the demographic of your audience? (are they male, female, young, old)

That is what Google Analytics gives you:

Who

Analytics will actually break down the demographics of your website visitors, this will help you understand who your audience is

What

It will also break down what they are actually doing on your website, how long they are spending on your website and are they following your CTA (call to actions).  If the reports show that you have a high bounce rate, it shows that they are not engaged with your content – giving you all the information you need to go away and review your content.

When

Understanding the trends of your site can help you mobilise your campaigns better.  If Analytics shows most of your visitors are on a specific day or timeframe, make sure you are posting to social media more that time of the day or publish a new post during that period to keep them on your site longer.  This will improve your rankings too.

How

More and more people are searching online via their smartphones, Google has recently changed its algorithms to focus on mobile first – so understanding the percentage of people searching for your site via mobile is important.  It is also really important your website is mobile friendly.

All of this information is really important when you are starting a blog, understanding what users are thinking of your site (staying on it or leaving it) is key to ensuring you can keep up and ensure your site gets better at keeping people on it to improve your rankings and grow traffic.

The 10-minute video below gives you a good overview of what Google Analytics gives you, including it’s benefits and the reason why you need to get it installed.

Now, let’s get into how you install Google Analytics on your WordPress website…

How to Sign up with Google

To get started with any of Google’s tools (Google Analytics, Google Search Console, etc.) you will need to have a Google account… So, that’s the first step…

How to Sign up with Google Analytics

Like all of the Google tools available to website owners, you will require a google or Gmail account.

Step 1: Visit the Google Analytics Sign up Page.  If you already have a google or Gmail account, then you can use these details to sign in.

If you do not have one yet, you will be prompted to create an account.

Step 2: Once you have signed in, you will be prompted with a screen like the one below:

how to add google analytics to wordpress-google signup

This is where you will sign up to a Google Analytics Account.

Step 3: On the next screen, you will be given the choice between a website or a mobile app.  Ensure you select website.

After that you will need to fill in some details.  An account name (it will be the profile name for this website in Google Analytics), Website Name, Website URL, Country and time zone.

google-analytics-new-property-website-

Once you have filled in the information, select ‘Get Tracking ID’.  You will see the terms and services agreement for using Google Analytics which you must agree to.

Step 4: Now you will see your Tracking ID (code).  You can copy this tracking code ready to paste into your WordPress website.  We will get into doing that in a moment.

Google Analytics - Website Added

We suggest you leave the browser tab open with your tracking ID detail, just in case you need to go back to it.

Now that we have setup a Google Analytics account, let’s go through adding that tracking ID to your WordPress website.

Once you’ve done this step, all you need to do is add Google Analytics to your WordPress website…

How to Add Google Analytics to WordPress

There are a couple of ways you can do this, one is more advanced that the other, but both work.  We’ll describe both methods, and include a video tutorial and then you can choose which is the best method for you…

Install Google Analytics in WordPress theme

Please note – changing the code of your website is really for advanced users who are familiar with website code. It is also worth pointing out that it is an unreliable method as it will require you to re-add the code anytime you change your theme or even update your current theme will remove the code.

If this is your first-time adding code to your WordPress website, it might be worth testing it out on a test website first. (Most serious bloggers or affiliate marketers will have a test site).

I will be running through how to add the code to your Header.php

Let’s go through the steps:

  1. Open up your WordPress Dashboard, Select Appearance and choose Editor
WordPress Menu Editor - adding Google Analytics

On the right-hand side of your screen will be a list of theme files, select header.php

Note, that some themes will warn you against changing the code of a website.

WordPress warning - editing theme

Once you click, I understand, you’ll then see a screen like this…

WordPress Theme Editor Screenshot - Adding Google Analytics

All the text you see on the screen, is information related to how your website looks, so we want to make sure we do not delete anything from this text file.  So we want to scroll down until you find atag.  Paste your tracking code in straight after this and save the file.

Reminder – you will need to redo this every time you update or change your theme.  Which can be a bit of a problem, considering how often WordPress and your theme will update, there is an alternative (and easier) way to do it though.  We’ll describe that to you shortly…

But for now, watch this video to see how you can add Google Analytics via the Theme editor.

Like I said, this can be a little more complicated than it sounds and you’ll need to do this each time your theme has an update.  That is why we prefer to use the All-in-One SEO plugin to add Google Analytics to your WordPress site.

How to Add Tracking Code to All-in-One SEO Plugin

An easier way to add your google analytics tracking code to your WordPress site is by adding it to the all-in-one SEO plugin.

The All-in-One SEO plugin is a great way of helping the search engines find your website and it allows you to add your tracking ID in the basic settings.  This is a much easier option than adding the tracking code to your theme, as it will not require you to update the code at all.

If you do not already have the All-in-One SEO plugin, Go to Plugins and select ‘Add New’.  Search for All in One SEO and install the plugin.

In the General Settings on the plugin, scroll down and you will find a box dedicated to Google Settings, including a box to add your tracking ID.  Paste your code into this box and you will never need to re add your tracking code unless you remove the all-in-one SEO plugin.

Viewing The Reports on Google Analytics

First things first, let’s look at the report for this website. it is currently a week old and the figures aren’t too bad for a new website:

google-analytics-overview

It shows me I have had 86 visitors in the last 7 days, the bounce rate is a little high but is reducing and they are spending around 1 minute on my site.

All of the reports in Google Analytics break this down to the post/page on my website.

The Different Headings all have great features to help you, let’s explore them:

Real Time

Once you get established, the real time feature is awesome as you can track what your visitors are doing whilst they are on the website.  Location, Traffic Sources (how did they get to your website), Content Report, Conversions – Set this up to see how many follow your CTA.

Audience

This has a number of great features all aimed at telling you exactly who your audience is, this will change as you establish your website – but it will definitely help you tailor your content to your audience.  If your audience is a younger or older age range than you originally thought, you may change your content to fit.  You find out your audience is more female than male – that can be helpful.  I.e. you have a niche website in male grooming, but more woman are visiting as they want to buy gifts for their partners – this can help you tailor the reviews of the product correctly.

Behaviour reports breakdown what they are doing on your website, do they visit one page and leave, or do they follow any Call to Actions you have or check out other pages?

Google Analytics Reports Menu

Acquisition

Where do your readers come from?  This tab allows you to track whether they are finding you via the search engines, social media or referral.  Really useful, social media will be a bigger pull until you are ranking better:

acquisition-report-google-analytics

The Conversions Tab is where you set yourself goals for your website and it will track them for you.

Conclusion

Google Analytics is such a powerful tool for your website, whether it be affiliate marketing or not it gives you such an insight into your website and what exactly is happening when someone visits your website and lets you know what you need to change to keep them on your website longer.

Hopefully now you know what benefits Google Analytics has, how to create an account and some information around what you will see when you add it to your website.

If you have any further questions about Google Analytics, the please write them in the comments below and I will come back to as soon as possible with an answer.
Thanks

Get Our 7-Day Passive Income Bootcamp For Beginners,
Absolutely FREE!

The Free 7-Day Course + Our Blueprint will be sent to the email address you submit below:

passive-income-bootcamp

4 thoughts on “How to Add Google Analytics to WordPress – It’s Easier Than You Think!”

  1. Hi John:

    I’m just now starting to use Google Analytics. Before now, it really didn’t make sense since my site is relatively new and not getting much traffic.

    This is very helpful information for a non-techie like myself.

    Can I add a tracking code if I am using Yoast instead of All in One SEO?

    Anyway, you have explained Google Analytics clearly and simply. Up until now, it seemed confusing.

    Thank you so much!

    Reply
    • Hi Christopher,

      thanks for your comments and taking the time to check out my post.

      I am glad you found it useful, and yes you can do it for the Yoast plugin.  it is very similar, but this video will explain it a little better.

      How to Install Google Analytics in Yoast

      I am glad you are getting your head around Google Analytics, if you have any further questions do not hesitate to get in touch with me.

      thanks again

      John

      Reply
  2. Hello,
    Google Analytics is very important for knowing where the traffic in your site is coming from and your most visited pages.
    Your post was really clear, using graphics and also the table of content at the beginning made it easy to understand and follow every step.
    Thank for this guide! It was really helpful!

    Reply
    • Hey,

      Thanks for taking the time to check out my post and leave your thoughts too!

      Thanks for your feedback on this post, I am glad you found it helpful.  Google Analytics is a key ingredient to any online business – and it is even better that it is free

      Thanks again

      John

      Reply

Leave a comment

Get Our 7-Day Passive Income Bootcamp For Beginners,
Absolutely FREE!

The Free 7-Day Course + Our Blueprint will be sent to the email address you submit below:

passive-income-bootcamp