There is a WordPress plugin for everything… including linking Google Analytics to your blog. I highly recommend against using such plug-ins, as they behave differently for some themes and your account may report incorrect data to you and any third parties that may be following your growth. Today I’m explaining how I learned this the hard way, what it meant to my blog income, and how I fixed it. Learn how and where to add your Google Analytics code to WordPress in the right place.
Discrepancies between Jetpack Stats and Google Analytics
I installed a Google Analytics plugin when I first started my family lifestyle blog, but I always found the Jetpack app visually easier to digest. As time went on, I rarely took the time to check in on my Google account at all. This was a huge mistake because my Google Analytics stats were being tracked by several influencer companies with the potential for future sponsored posts, so I really should have kept an eye on things.
Back in April, my traffic more than doubled. Interest in my blog exploded, and I had to turn down quite a bit of work because I wanted to keep the ratio of paid to unpaid posts sensible to remain authentic. This flow of paid campaigns continued into May, and amongst all the writing and promoting I decided to give my site a makeover and install a new theme. One of the things that attracted me to this theme was the unique landing page. My blog homepage now had an awesome design that shouted ‘welcome, look around.
What I didn’t realize was my Google Analytics code was no longer installed on my homepage through the plugin. So the hits being tracked did not include my homepage, which is obviously a popular second click page.
By the end of May, the sponsored post offers were starting to slow. I put it down to the summer break as a lot of my sponsored opportunities are family/parenting-related. In August, I decided to check into my Google Analytics to check on my bounce rate… were people enjoying my site enough to click around? Not only was my bounce rate crazy high, but my page views were also almost half what they were showing in Jetpack. So as far as influencer companies were concerned, traffic had plummeted.
Where to Add Your Google Analytics Code to WordPress
Editing code may seem daunting, but it’s really quite simple and may save you problems in the future. You just need to know where to find the tracking code within Google Analytics, and where to paste it…
Step 1: Log into Google Analytics & Find Your Tracking Code
Once logged in to Analytics, click on the admin button at the bottom of the left-hand navigation bar. The icon looks like a cog. You should see three-column menus, go to the middle menu ‘Property‘ and click on ‘Tracking Info‘. The menu will expand, click on ‘Tracking code‘. Inside the ‘Website Tracking‘ box is the code you need to copy. You want to highlight and copy the entire text contained in this box, including the <script> tags.
Step 2: Log into WordPress & Find Your Header File
Once logged into WordPress (I have a self-hosted site published through WordPress.org), hover over ‘Appearance‘ half way down the left-hand main menu. A sub-menu will open up, at the bottom click ‘Editor‘. On the right-hand side, the gray menu lists all your files. Scroll down and click on ‘header.php‘ Don’t freak out when you see “Editing this code is highly discouraged. Proceed with caution.” You’ll be fine… click ‘Proceed‘.
Step 3: Add your Google Analytics code to WordPress
Once the header.php file is open you will see the code. Not far down the page, locate the </head> tag (Note: this is not the same the <head> tag… without the slash opens the code, with the slash closes the code) Click the cursor immediately before </head> and press return to make a new line. Once on a new line above </head>, paste your Google Analytics tracking code. Scroll down to below the editing box and press ‘update file‘.
You tracking code is now installed and data will start to be sent to Google Analytics!
Don’t Forget to Deactivate your Google Analytics Plugin
If you do not remove your plugin, your bounce rate will drop dramatically. This might sound great but no one is going to believe a reported bounce rate of 0.3%. What we’re trying to achieve is genuine tracking of activity. By having the code and the plugin installed at the same time, Google is tracking each page click twice, meaning it looks like every single person that visits a page, visits another page… no-one ‘bounces’. Just deactivate/delete the plugin after your code is installed and all data should be reported accurately.
I hope this tutorial has been useful and you now know where to add your Google Analytics code. Do get in touch if you have any questions!