Adding google analytics tracking code to your WordPress installation the easy way

Insert your tracking code generated from google analytics into your footer.php for your specific theme that your blog uses, WARNING! if you switch themes you will need to go back and add that tracking code to the new theme!

wp-contentthemesyourthemenameherefooter.php and do a search for the </body> tag.

Directly above the </body> tag paste in the code given to you by Google analytics. It should like something like this:

The new google tracking code:
<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”>
var pageTracker = _gat._getTracker(“UA-1292736-8”);
pageTracker._initData();
pageTracker._trackPageview();
</script>

Or the old google (urchin) tracking code:
<script src=”http://www.google-analytics.com/urchin.js” type=”text/javascript”>
</script>
<script type=”text/javascript”>
_uacct = “UA-1234567-8″;
urchinTracker();
</script>

After adding the code for your specific website upload it to your correct theme folder using ftp.

Leave a comment