Follow kevinlearynet on Twitter!

kevinleary.net

How to Add Google Analytics to Wordpress

So you’ve signed up for Google Analytics and you want to set it up on your Wordpress blog.

Get the Ultimate Google Analytics Plugin

Download and install the plugin, log in to your Wordpress control panel, and then enter your Google Analytics account ID under Settings \ Ultimate GA.

What is a Google Analytics Account ID?

1
2
3
4
5
6
7
8
9
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-XXXXXXX-X");
pageTracker._trackPageview();
} catch(err) {}</script>

In this case var pageTracker = _gat._getTracker(“UA-XXXXXXX-X”); shows your Google Account ID to be UA-XXXXXXX-X.

Advanced Features

Ultimate Google Analytics has a number of advanced features you can integrate with your Google Analytics account to track the number of clicks to download links, mailto links and outgoing links.

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

2 Comments

  1. Christopher Ross / 4.28.09 / 8:20 AM

    hey Kevin, remember that for those who have access to the theme files they can also open and add the Google code directly into their footer.php file (between the body and html tag) if they want to avoid using the plugin.

  2. kevin / 4.29.09 / 11:12 PM

    Always true Chris, and for developers that may be the easiest way. The one advantage to this method is that you can upload and install the plugin without access to FTP. You also have advanced Google Analytics features built in like download, email and outgoing link tracking.

Leave a comment

will not be published

Wrap code blocks with <pre lang="LANGUAGE" line="1"> and </pre> where LANGUAGE is a GeSHi supported language syntax.