Google Analytics for WordPress


Analyze your visitors behavior easily!

  • Start tracking with just a few clicks
    No copying of tracking codes, no issues with “where do I place the tracking code”, the plugin does it for you!
  • Track loads of metadata easily
    Want to see page views per author? Or per post type? Or per category? The plugin can track all that metadata for you, making your analysis much more useful.
  • Have specific needs? Easily extendible!
    If you want to track specific info, the plugin is easily extendable. Simply check the API docs below and you’re on your way!

Download this Free Plugin »

When you have a website, you want to track how many visitors you have, where they come from, what they do on your site and much, much more. Google Analytics is the de-facto standard for measuring this, and much more. Adding Google Analytics to your website is as easy as pie with the Google Analytics for WordPress plugin.

Often times, people just copy the Google Analytics tracking code into their theme, and that’s it. This leaves a lot of powerful features of Google Analytics unused. This Google Analytics plugin opens up those features for you to use in a very simple way.

So What does this Google Analytics plugin do?

Check out the video for an introduction, or read on below it:

Basic tracking

First of all, this plugin makes sure you’re using the latest tracking code. This way you’ll benefit from all Google Analytics offers and use the fastest method of embedding it on your site. Adding the tracking is very easy; once you’ve installed and activated the plugin, you can click on the authenticate button:

Google Analytics for WordPress: authenticate with Google Analytics

If you’re not logged in, Google will ask you to log in, if you are, it’ll show you the following screen:

Google Analytics - Grant access

Clicking the button will redirect you back to your Google Analytics for WordPress settings page, where you can now select the profile you want to track:


Once you’ve selected the right profile, you can click save, and that’s it! You’re now using Google Analytics on your website! But of course, we’re only just getting started, the true power comes from tracking outbound clicks and PDF downloads and using the custom variables that Google Analytics allows you to set.

Tracking downloads and outbound clicks

By default, Google Analytics only gives you statistics for your pages on your website. If someone clicks on a link to leave that page, you’ll never know… If someone downloads a PDF, you’ll never know either. Simply checking the “Track outbound clicks & downloads” checkbox will change this. It will allow you to see, in Analytics, what people clicked on and what they downloaded.

You’ll find this data in Google Analytics under Content -> Events. The data is categorized into several categories:

  • download: tracks the number of downloads.
  • outbound-article: this tracks the number of clicks on links in articles.
  • outbound-comment: tracks clicks on links in comments.
  • outbound-commentauthor: track clicks on the links for comment authors.

This data becomes more interesting when combined with other data, of course!

Custom Variables

Custom variables allow you to store “extra” info, on three levels: a page level, a user level or a “session” level. This allows us to store, along with the basics like the URL, extra info about the page being visited or the visitor. For instance, the name of the author, so you can run stats on your site to see page views per author. Or you could track the category, so you can see analytics per category. Or: you could do both! Google Analytics allows you to set 5 custom variables, and the Google Analytics for WordPress plugin currently has 7 values you can store:

  • Logged in users: speaks for itself, very useful on BuddyPress sites etc: where do people that are logged in go, where do others go. It stores the user’s primary user level in the variable, so you can even segment for just “subscribers”. (There’s an advanced option to ignore users of certain levels should you want to btw)
  • Author name: track page views per author.
  • Single category: if your posts are in only one category each, this allows you to track views per category.
  • All categories: track multiple categories per post, a bit harder to view in Analytics, but could still be useful.
  • Tags: track all tags for each post, has its limits but might be useful.
  • Publication year: see what’s doing good and bad, more specifically whether your old posts are still getting traffic.
  • Post type: this is very useful if you have multiple post types: if you’ve got movies, actors etc. set up as custom post types, this allows you to track how many page views each post type got.

So you could run reports showing which authors do better, which categories and / or post types get more page views and so on. This will provide you with the kind of analysis you need to improve your site. To use this functionality, first check the checkbox for “Show Advanced Settings”, then you’ll see the following box:

Google Analytics for WordPress: custom variables

Just select the custom variables you want to track and click update. The plugin will do all the heavy lifting for you. One of the cool things you can do using this data is set up a custom Google Analytics dashboard. A nice example of such a dashboard can be find in our Google Analytics Dashboard for your blog post.

An API for this plugin

This plugin adds a couple of filters so you can add your own tracking from your own plugins without having to hassle with the rest of the tracking. The 3 filters are:

$push = apply_filters('yoast-ga-custom-vars',$push, $customvarslot);
$push = apply_filters('yoast-ga-push-before-pageview',$push);
$push = apply_filters('yoast-ga-push-after-pageview',$push);

Custom variables are hard to deal with, as they need to be in the same “slot” all the time, that’s why the $customvarslot is passed along.

Go get the Google Analytics for WordPress plugin

I have to believe that I’ve convinced you by now: