How to Add Google Analytics to WordPress in Under 60 Seconds

There’s no doubt Google Analytics sets the standard when it comes to gathering information on your site’s visitors.

Analytics can show where they landed on your site, what they read, how long they stayed, what they were searching, the browser they were using, where they live, their age and even their interests.

Adding Google Analytics to your site is easy. So simple, in fact, that it takes less than a minute!

For today’s Weekend WordPress Project, I’ll show you how to add Google Analytics to WordPress with very little time and effort.

Feature image
Add Google Analytics to your side in under a minute.

1. Login to your Google Analytics Account

This tutorial assumes you’ve already signed up for Google Analytics. If you haven’t already got one, it only takes a second to sign up, especially if you’ve already got an account with Google. Head to the Google Analytics site and create a new account.

After you’ve signed up, you’ll be given a piece of Javascript code to add to your site.

Tracking code
After signing up for Google Analytics, you’ll be given some code to put in your site.

2. Add the Google Analytics Code to Your WordPress Theme

Copy the tracking code. Go to your WordPress Admin and then Appearance > Editor.

Open your theme’s header.php file and directory underneath the < body > tag, paste the tracking code. Click “Update File”.

Adding code to header
Add the tracking code directly below the < body > tag.

3. Check Analytics is Working On Your Site

Receiving data
Once you’ve insert the tracking code into your theme, your Google Analytics tracking should change.

Go back to your Google Analytics account. Click on “Admin” at the top of the page and under “Property” choose your site and then click “Tracking Info”.

If the Tracking Status is “Receiving Data,” then you’ve successfully added Google Analytics to your site.

You can now click on the “Reporting” tab at the top of the page to see your site’s analytics overview. It may take Google up to 12-24 hours to start providing you with site stats.

Or… Just Use a Plugin

If you don’t want to edit your theme files, Google Analytics + is the plugin you need.

It puts all the important statistics at your fingertips by adding beautiful charts and graphs to your dashboard and the post edit screen.

View statistics for individual posts, a site or even an entire Multisite network without having to leave your WordPress backend.

A new one-click Google login process allows easy access to your analytics. Simply add a new account ID in the network settings to start collecting data for your entire multisite network.

Comments (5)

  1. Is there any reason to put it under tag? Usually it’s included through functions.php or directly before closing tag. Is there any benefits from this approach?

  2. Nice post.

    I have just redesigned a website for a friend. He had google analytics set up and working fine. They website is made with wordpress.

    After the redesign (finished 3 days ago) google analytics are no longer coming in. Under “Status” in google analytics it says “receiving data”.

    Can i simply add the tracking code again via the plugin like you did and everything will start working again?

    • You’ll need to check the site for the tracking code, though if it’s not there you can log in to your friend’s Google Analytics and copy the tracking code there and paste it into the site as per my tutorial above. Good luck with it!

Participate