Axel Amer
Founder at BlueNest agency
Home / Blog / WordPress / How to add Google Analytics to WordPress
Welcome, dear agency owners, every website is just a tool, and value is created by doing something like generating leads through SEO, Social Media or PPC campaigns – anyway, you’ll need to install any analytics, so today we’ll talk about the most popular Analytics for Web – Google Analytics.
The basic answer is to know where your visitors and leads are coming from. Without analytics, you won’t be able to measure the scale and success of an aqcuisition channel, and your marketing will be stuck in the darkness. However, having analytics opens your eyes on situation with a website in real time and in past periods:
Just navigate to the main Google Analytics webpage and hit “Go to Analytics”. You’ll be asked to log in and that’s where creation starts.
2. Property creation – will track something like website data or app data
3. Select business size and category
4. Select why you’re going to use Google Analytics
After saying “yes” to all legal data, entering your website URL and label to the created analytics, and specifying web/ios/Android platform for using analytics – You’ll see the code that should go to the website. The main thing here is the ID – on the screenshot it’s “G-QS2HN4QQC1” – now we need to add this code to the website
Basically, there are 2 ways, and really, if you don’t know what to do, I’d recommend the plugin. It’s official recommendation from Google for WordPress and should work in 9 out of 10 situations and then we’ll move to that 1 of 10 situations
Search through the plugin directory or download the Site Kit directly from the Google plugin from the main plugin directory and authenticate with your Google account. In a few clicks you will be able to add one or multiple tracking tools:
For somebody who’s not a developer himself, a pretty useful plugin. Each tool have separate toggler to activate. Best solutions for non-devs. Even this website uses this plugin because I like it, really.
Welcome to the advanced territory. Now you’ll be operating with code. Nothing crucial though, but a lot of questions could be answered with “it depends”. So, first we’ll try to add the code under header.php file
Go to WP admin -> Appearence -> File Editor ( For classic themes ) and find header.php file
The task is not finished if it’s not tested properly, so now you need to flush all caches, visit your Google Analytics real-time reports, and open a certain page on the website. Under real-time reports, you should see your own activity or your + other visitors’ activity.
Google says you should wait 24 hours to aggregate the data – but it’s not the same for real-time reports. If after 1 hour analytics still not showing any data on real-time reports – means it
Easy to add, but also easy to mess up. Most common analytics issues seems like:
First of all, a basic check is to open the page source code and verify that the code is output on the page and that the ID is correct. If it’s there – data should be tracked.
Second, if some data is not tracked – you may have some JS issues or Optimisation issues and it’s time to reach out to developer to investigate this, remove all the analytics and set up it again.
Double/tripple data is tracked means you may have Google Analytics installed in few places – usually it’s GTM and Plugin or GTM and Code, but definitely two tracking codes on the page
Follow the guide, flush the cache, and don’t hesitate to reach out to me on LinkedIn if none of the methods above worked – and I’ll do my best to help you out and update the guide after that.
In my opinion, 9 of 10 situations – agency owners, PMs or Marketing or SEO managers should be able to do this job themselves. I’ll do a screencast shortly to help out with the step by step guide plus screen recording for maximum confidence.
Best of luck with client’s projects