Google Analytics For WordPress

The Google Analytics (GA) plugin lets you easily add Google's web tracking script to your WordPress site.

Google Analytics is a truly amazing service for marketers: it generates comprehensive site statistics for your site — at no cost — that are entirely geared towards website optimization (quick tour). The only downside is that Google ends up knowing your stats. If you do not wish it to, look into the Hitslink plugin.

Google Analytics Tour

Click to see a Tour of Google Analytics

To make use of the plugin, browse Settings / Google Analytics and paste the code that GA provided you with for your site, and you're pretty much done.

Note that site authors are not tracked so as to not pollute your stats.

This plugin contrasts with a number of similar WordPress plugins, in the amount of effort that was put into making it easy to use, and into integrating other plugins so you can make the best of your stats.

AdSense integration

AdSense integration is built-in. As soon as you tie your GA account to your AdSense account, GA will start tracking revenues and clicks, on a per keyword and on a per page basis.

To take full advantage of this, filter your GA reports using custom, Advanced Segments. Oftentimes, these will allow you to discover stunning — not to mention unintuitive — things about your site and its visitors.

Ad Manager integration

The Ad Manager plugin makes GA track any click on its ad widgets as GA events, provided the click doesn't occur in an iframe tag. (Their provider's AUP generally disallows to change their code.)

Contact Form integration

The Contact Form plugin makes GA track contact form usage as GA events.

Mediacaster integration

The Mediacaster plugin makes GA track file downloads and media player usage (play, stop, completed video or podcast, and so on) as GA events.

Newsletter Manager integration

The Newsletter Manager plugin makes GA track subscription form usage as GA events. It will additionally segment users who subscribe to your mailing lists, allow you to track what they do once subscribed in a convenient report.

404 error and outbound link tracking

Page not found errors on your site are tracked as /404/?page=…&from=…

Clicks on outbound links are tracked as /outbound/?to=…

Search tracking

Search tracking is built into Google Analytics: edit your site's profile in GA, and add the "s" parameter as a search query parameter.

Domain-wide tracking

This feature is still experimental, but nonetheless worth a note if you wish to track your domain and all of its subdomains in a single report. Simply add a define in your wp-config.php file as follows:

define('GA_DOMAIN', '.example.com');

At the time of writing, doing so will turn off media player usage tracking, hence the "experimental." Everything else works fine.

To make the best of the resulting reports, customize the way your reports are displayed by creating an advanced filter for that domain's profile:

Filter Type: Custom filter / Advanced
Field A: Hostname
Extract A: (.*)
Field B: Request URI
Extract B: (.*)
Output To: Request URI
Constructor: $A1$B1

You'll then be able to your various subdomains directly.

Custom event tracking

The GA lastly allows to track custom-defined events, in case the need arises. Doing so is relatively easy, too: simply add a ga_event class to your <a>, <div> or <form> tag of interest.

Download

This package is part of Semiologic Pro, and is access-restricted.

Bleeding Edge Zip

Frequently Asked Questions

The Semiologic forum is the best place to report issues.

Change Log

Version 6.0

  • Support new Universal Analytics tracking code.
  • Adds option to turn on Display Tracking when using Universal Analytics.
  • Adsense tracking is only available when using a Semiologic theme.
  • Fix Event Tracking failing to track some events with some caching plugins that concat javascript files.

Version 5.2

  • Use minimized javascript for better site performance
  • Code refactoring
  • WP 3.9 compat

Version 5.1

  • Perform Keyword Rank Tracking for other Google sites and not just google.com searches.
  • WP 3.8 compat

Version 5.0

  • Added option to turn on cross-domain tracking
  • Outbound links are now tracked as Events as well as Pageviews
  • File downloads, mailto: and tel: links now tracked as events
  • Added Keyword Ranking tracking code per A New Method to Track Keyword Ranking using Google Analytics
  • Internal links that start with http:// were incorrectly being tracked as outbound links
  • Fixed conflict with wp-polls that caused the tracking code to be included twice
  • Updated help links in the Settings screen to latest Google help information
  • WP 3.6 compat
  • PHP 5.4 compat

Version 4.3

  • WP 3.5 compat
  • Changed sequence of subdomain tracking javascript code now that feature is in production

Version 4.2

  • Use the asynchronous tracker.

Version 4.1.1

  • WP 3.0.1 compat

Version 4.1

  • WP 3.0 compat

Version 4.0.1

  • Localization enhancements

Version 4.0

  • Complete rewrite
  • Localization
  • Event tracking
  • Improved 404 and outbound link tracking
  • Code enhancements and optimizations