kevinleary.net

How to Add Google Analytics to WordPress

So you’ve signed up for Google Ana­lyt­ics and you want to set it up on your Word­Press blog.

Get the Ulti­mate Google Ana­lyt­ics Plugin

Down­load and install the plu­gin, log in to your Word­Press con­trol panel, and then enter your Google Ana­lyt­ics account ID under Set­tings \ Ulti­mate GA.

What is a Google Ana­lyt­ics 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 page­Tracker = _gat._getTracker(“UA-XXXXXXX-X”); shows your Google Account ID to be UA-XXXXXXX-X.

Advanced Fea­tures

Ulti­mate Google Ana­lyt­ics has a num­ber of advanced fea­tures you can inte­grate with your Google Ana­lyt­ics account to track the num­ber of clicks to down­load links, mailto links and out­go­ing links.

2 Comments

  1. Christopher Ross / 4.28.09 / 8:20 AM

    hey Kevin, remem­ber 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 devel­op­ers that may be the eas­i­est way. The one advan­tage to this method is that you can upload and install the plu­gin with­out access to FTP. You also have advanced Google Ana­lyt­ics fea­tures built in like down­load, email and out­go­ing 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.