Tutorial to add Google Analytics to your WordPress website

Tutorial to add Google Analytics to your WordPress website

Google Analytics is a product by Google that helps you gain some very nice and powerful insights about your site’s traffic. Even though I won’t call it a “complete” solution to your site’s analytics, it does the job neatly and it is FREE!

You can get a lot of insights about the kind of traffic your site gets. So what to do with those insights? It is up to you. But without those insights you are blind. And you are blindly shooting at the star.

With analytics, you can point and shoot. You can fine tune your strategies. And you can clearly see what works and what doesn’t!

Well, well it is all nice! But I’m not a tech geek. I don’t like the word “install”. I can create and publish content on my WordPress blog and that’s all I can do. How do I “install” something like Google Analytics on my WordPress blog?

Well, let’s get to it in this blog post.

What is Google Analytics?

If you really don’t know what the heck Google Analytics is, here’s a gist in layman’s terms. It is a product provided by Google. You can use that on your site by creating an account for yourself. You then add your website in Google Analytics, grab a piece of code that it offers and paste that code on your website (more on this later).

That code acts as a connector between your website and Google Analytics program. The code essentially tells Google Analytics all the neat information about who’s visiting your site, where did they come from, did you manage to impress them or not and what car they are driving (well, not this one).

Knowing about your site’s traffic, where it came from, how long the visitors stay and other details like this is something very crucial for your business. Without measuring precisely what’s going on, you won’t be able to improve it, right? Google Analytics will help you measure some of the crucial metrics so you can see (yes, visually) what’s going on, what needs to be improved and what’s paying off.

I will write a separate post on how to make use of Google Analytics data to improve your website – but for now, let’s get started with installing Google Analytics on your website.

How to install Google Analytics on your WordPress website?

I assume you already have a Google Analytics account. No? OK, let’s signup for one (its free!).

Go to https://www.google.com/analytics/web/ > and sign up for a new account. If you are using a browser where you have already logged in to your Gmail, then you will be prompted to login/create account using your Gmail account – if you have logged in to multiple Google accounts, just choose the one you prefer.

Once you have created your account and once you are logged in, go to Admin, and click on “Create New Account” as shown below:

Google Analytics - Create New Account

In my Analytics account, I already have added a few sites – so I have a long list and I see “Create New Account” at the bottom. If your account is new, you should just have the option to create a new account.

When you are on the New Account creation page, everything is self explanatory. For Account Name and Website Name fields I usually put the name of the website, for instance, Best Hosting And Design.

Then input your website URL – example of my case would be > https://www.besthostinganddesign.com (you need to include http://)

Select a category (for Industry). Choose a time zone so you can see the report(s) in that time zone. This is usually the time zone that YOU prefer to have the stats at. I live in India – so I choose my own time zone.

I leave the rest of the check boxes ticked (they’re ticked by default). Once you are done filling out all the info (and having checked if everything is right), click on Get Tracking ID.

Google Analytics - Get Tracking ID

You will be prompted to accept the terms and conditions of Google Analytics. Click on “I Accept”, if you do, after having read it!

You will then see a page like the one showed below where you will have a piece of code to grab. Clicking inside the box will select all of the code. Copy it (and optionally paste it into a notepad).

Google Analytics - Tracking code

Now depending upon the theme you choose, you have different options to add the code to your website.

Add Google Analytics code in the site header or footer

If you have a premium theme like Genesis (which I highly recommend, by the way), you will have an option to add Analytics code in the Theme Settings. If it is Genesis, go to Theme Settings and scroll down to see “Header and Footer Scripts” and input the code you copied into the wp_head() box. If you have a premium theme that is other than Genesis, you should still be able to find a similar place to input your code.

Google Analytics - Header and Footer Scripts

If yours is not a premium theme, then you might not have the option to easily paste the code in a box. In that case, go to Appearance > Editor in your WordPress dashboard and then choose header.php from the list of files to edit.

choose header.php from the list of files to edit

Inside header.php, find class (you can use ctrl or cmd + F to find for <body) and paste the Google Analytics code right after it.

Google Analytics - header script

Don’t forget to save the file once you are done.

Use a plugin to add Google Analytics – the simple way

If you don’t want to deal with editing codes and finding boxes, you can very well use a plugin! When it comes to WordPress you have a plugin for almost anything (which is both a blessing AND a curse, by the way!).

There are lots of plugins that could do this job but I’d recommend Google Analytics by Yoast. Install and activate this plugin in your WordPress site. Once that is done, go to Plugins page and scroll to find out Google Analytics by Yoast and then click on its Settings.

There you can either Authenticate with your Google Profile or you could manually enter the UA code. I’d prefer authenticating via Google Profile, but if you want to do it manually, go to Google Analytics account. Click on the website from the list of sites (you’ll see only one site if you added just one). Once you have clicked/selected the particular website, click on “Admin” from the top menu.

Google analytics - Admin

Then under “Property”, choose “Property Settings” – you’ll see the Tracking ID – it will be in the following format > UA-XXXXXXXX-X – where, all the “X” are numbers. Copy that ID.

Google Analytics - Property Settings

Paste it inside the box where it says Manually enter your UA code and save settings. You could leave the other settings as such, or you could go through them and choose the settings you want.

Yoast google analytics

This is a really neat plugin and makes your jobs easier when it comes to adding Google Analytics to your WordPress site.

Have you added Google Analytics to your website? Which method did you use? Did you find any challenging moments?

About the Author

I'm Jane, the owner of Best Hosting And Design, where I help bloggers and website owners to create and maintain their websites. Check out the services I offer here so you can make use of them. For cutting-edge business tips, please head over to Jane Sheeba.

Leave a Reply 2 comments

Jasper Brooks - March 5, 2015 Reply

Google Analytics is really effective and I find it useful to my site. By the way, your tips are impressive. Have you encountered any errors when you first used the analytics for your site’s traffic?

Tolga Ayan - October 18, 2016 Reply

Hi Jane.

Your article is really explanatory and helpful.

Thank you

Leave a Reply: