Installing Analytics the Google Way

I thought Monster Insights was a great way to install Google Analytics on my website but maybe I was wrong!

Because Google stores data about every visitor there’s a lot of data protection laws that we need to abide by such as GDPR (General Data Protection Regulation). One of the best ways to make sure we are covering ourselves is by anonymizing our visitors IP addresses before Google takes it and analyzes the data. Monster Insights have a button that does that all for us but it wasn’t until I went to turn it on that I found it was behind the Pro wall and needed to be paid for. I’m happy to pay for pro versions but after a bit of research, I discovered I could anonymize IP addresses myself by installing Google Analytics the Google way! This meant disabling Monster Insights and doing it the old fashioned way with a bit of coding.

If you really do want to avoid touching any code then Monster Insights is great, I just don’t want to have to pay for more advanced features. Monster Insights is featured in my Getting Started With Google Analytics post.

Adding the coding to install Analytics

I’m no coding wizard but I’ve done my research and found it’s actually really easy to install Google Analytics ourselves, it’s just a copy and paste job really. First, we need our tracking code we can find this on our Admin page – Tracking Info – Tracking Code, below shows you the page you will be presented with and the code (Highlighted within the pink box) that you will need to install Google Analytics on your WordPress website. I’ve blurred out my unique ID.

Select and copy this piece of coding and head over to your WordPress Dashboard. From here we want to go to Appearance and Theme Editor, this will bring you to the files that make up your theme so be very careful here! On the right-hand side, we want to find the file that is called ‘Header‘ or something along those lines, depending on the theme you have installed it may vary slightly, mines called ‘Header.php‘.

Now all we need to do is find the </head> tag and paste our code directly above it. It should look something like the image below.

TIP: If you’re finding it hard to find the </head> tag within the code press CTRL F on your keyboard and use the search function to find it.

Header Code

Once pasted in click on Update File at the bottom and that’s it! Now all we need to do is test that our code is working.

Testing our google analytics installation

To make sure that we copied and pasted our tracking code correctly we can now test it within our Google Analytics admin panel. In our Google Analytics account go to Admin – Tracking Info – Tracking Code here we will see a button called ‘Send test traffic‘ this basically sends Google over to our site and if successful it will update the number of active users displayed above the button.

Test Traffic

It may take around 30 seconds to update the traffic figure but if nothing changes for over a minute we may need to go back and check we have installed the code correctly.

That’s it! We’ve successfully installing Google Analytics on our WordPress website! This code will automatically add itself to every new page we create so we don’t have to worry about editing this code again, unless of course we want to add more functions. In my next post I will be covering what we need to add so that our visitors IP addresses are anonymized before being sent to Google for analyzing, this is advised if we have enabled demographic and interest tracking to comply with GDPR.

Leave a Comment

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

Share via
Copy link
Powered by Social Snap