How To Install Google Analytics into Your WordPress Site

How To Install Google Analytics into Your WordPress Site

I'm not going to sell you on the importance of tracking your website traffic. If you're reading this you are already on board, so let's just jump into it.

Upon creating the site tracking in Google Analytics, you'll be given a code that looks like this:

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-12345678-910', 'auto');
ga('send', 'pageview');

</script>

Copy this code. We'll need it in the next steps.

Installing the Google Analytics Code

Log into your WordPress site — note that it must be a self-hosted WordPress site and not one at WordPress.com. From here you have a couple options. The most direct method is to visit the 'Appearance' heading on the sidebar and select 'Editor'.

Along the right hand side you'll see a list of different .php files. Most themes show this anyway; if you had a custom theme developed it may not show everything. What you're looking for is the header.php file.

Within the header.php, use the CTRL+F command to search for "/head" and put your cursor just before that once you've found it. Hit enter a few times to insert some blank lines and paste the Google tracking code here. This will include the code in the <head> of every page on your website just before the head terminates.

You can also use plugins to simplify this process. These allow you to simply paste your tracking code into the plugin, and it will put it where it needs to go. Some themes also have a place to paste Analytics code under the theme options.

If you're stuck, watch this excellent video from wpbeginner.com:

With Google Analytics you can track far more than simply how many people came to your site in the last 30 days. (Though even just reviewing that info each month can be useful to track advertising etc.)

Other significant aspects of your site traffic you can track include:

  • How many visits per page of your site — see your top content and make decisions about what things have been successful.
  • How long people spent (on average) on each page of your site. This helps to determine what content is most engaging and if people are finding what they're looking for.
  • Bounce rate. This can be determine by site load speed, how easily readers can find what they need, or other design reasons. By itself the number isn't very telling (unless it's really high), but comparing one page to another can be useful to see what's working and what isn't as far as attracting readers.
  • Where your traffic comes from. This is even more important than the total traffic as a whole. Understanding how many visits came from Google searches versus social media, links from other websites, and more can help you draw further conclusions about your marketing efforts. It may lead to adjusting page content or refocusing external marketing efforts, and can be a great way to easily track the success of ad campaigns, guest posts, or popular shares on social media.

We'll cover ways to set up and interpret Google Analytics reports in another post, but this should get you started and get your site generating useful traffic data.

What's your SEO score?

Use our free SEO audit tool to see how any page in your current site is optimized for a target keyword. We'll also show you how you stack up against one of your competitors!

Leave a Comment

You must be logged in to post a comment.

design|One|web

design|One|web