Website Design Hub

how-to-load-google-analytics-on-wordpress

How to add Analytics to WordPress

Before we get into this I should point out that this How-to Tutorial is pointed towards adding the Google Analytics code to your Header, manually and without using a plugin.

There are quite a few reasons why I prefer this method but let me highlight something really quick. If you are installing a plugin for the sole reason of adding your analytics code to your website, that’s just wrong on so many levels. Plugins are designed to simplify the process of developing or designing a website but adding a bit of copy and paste code to your header.php file is really not complicated.

Relax though, you aren’t to blame – WordPress is opensource and some of those plugin developers can be pesky scam artists because it will take you a lot quicker adding the code manually than search in WordPress Repository for a suitable plugin and installing and setting it up – And trust me, this instruction article isn’t by any means the only one out there.

It’s technically safer but by no means difficult and requires but a few steps. Follow this exactly and you won’t run into any issues – In case you do though, we’re not responsible for any problems that may arise from this, so please be sure you have a back up of your site, just in case 😉

So, off we go!

Step 1:

In your WordPress Dashboard – Hover over “Appearance” in the sidebar, then in the sub-menu, click “Theme Editor”

wordpress-appearance-theme-editor

Step 2:

Next, head over to the right and click on the “header.php” file – Importantly, on some themes or on older versions of WordPress, you may get a file title but not the actual file name, in that case, the title will be at the top and the file name will be at the bottom – Make sure you click on “header.php” ONLY IN ALL CASES.

wordpress-theme-editor-headerphp

Step 3:

Head on to Google Analytics Tracking code – If you don’t know where to find it, it’s simple. When in your Analytics Dashboard, simply look at the bottom left of your screen and select “Admin”, then within the middle (property) column, click on the fourth option from the top called “Traffic Info” then select “Tracking Code” and you’ll find the screen shown below.

Step 4:

This is how simple it really is, even Google tells you what to do which I’ve circled for you to see – So basically copy and paste the code as the first item into the <head>.

So, then, we go ahead and copy the code below and move over to the following screenshot.

wordpress-analytics-g-tag

Step 5:

So back at WordPress, you’ll find the <head> tag and paste the code from Analytics directly UNDER (Following the line after) – Importantly for those not very familiar with php, you’ll find two HEAD Tags, one that looks like this <head> and a closing tag that looks like this </head> – This code ALWAYS gets copied in the opening tag <head>.

I know I may have confused you or made you read twice or thrise but if you don’t know php or if you’re not familiar with it, it can be confusing and we have endless problems with customers confusing the two or assuming they are the same thing – Even our newbie Website Designers have no idea what that stuff means until we teach them some php kung-fu.

wordpress-theme-editor-headerphp-head

Step 6:

This step is kinda easy, or at least the easiest on this How-To… See, I made you read more than absolutely necessary 😉 Just click update and you’re done 🙂

wordpress-theme-editor-headerphp-update-file

 

Step 7:

This step is about making sure you’re coding skills paid off – So head back to Analytics, open up your website in a new tab or window and wait a few seconds and you’ll see the “0” turn to “1, etc.” meaning that Analytics is working!

wordpress-analytics-receiving-test-traffic

Congratulations! If this was a first of many for you as a Designer or a small Business Owner starting up his first website, you just did a bit of coding and you can now see who’s visiting your site, where they’re going and what they’re doing.

I hope you’ve found this How-To Instruction super easy and wish you all the best in your website design or development journey – Remember, we’re always here for support just visit our Contact page and fill in the form.

Till next time…

Cheerios!!!

webdesignhub
Rapheala Scabia
Crazy, Fun and Outspoken Web Designer & Developer at Webdesign Hub

3 thoughts on “How to add Analytics to WordPress”

Leave a Comment

Your email address will not be published. Required fields are marked *