Okay, so I’ve written a small guide on how to implement Google Analytics on a WordPress site. This differs a little to the standard implementation on HTML pages as WordPress primarily deals with PHP and HTML templates.
To get started, sign up for Google Analytics at: http://www.google.com/analytics/
Once signed up, in the accounts interface (on the new version), select the cog in the upper right hand portion of the screen and select ‘+ New Account’.
Once you have specified the account name, URL and timezone, Google Analytics will generate some JavaScript code generally known as the ‘base tag’. This needs to be entered on every single page on your site to allow Google Analytics to capture user data and direct it to the appropriate account. Once this is generated, select whether this is a single domain, single domain with multiple sub-domains or multi top level domains. In this example, I will be using a single domain. You can also select here whether you are tracking via AdWords campaigns (this can be enabled at a later time however).
You will now need to copy all of the base tag code (paste it somewhere you can easily access like Notepad). As mentioned earlier, WordPress primarily deals with PHP functions and templates, so this code won’t be implemented in the usual <Head> tag of a HTML page. Instead, you will need to place this in the following location on the server that hosts your WordPress site:
wp-content > themes > theme currently used > footer.php
Note: ‘theme currently used’ should be replaced with the theme you have enabled in the WordPress interface.
The base tag code should be pasted directly before the closing of the </body> tag in the footer.php page.
Once this has been saved, you can open up any page of your WordPress site, view the source and you should see the Google Analytics base tag present on bottom of each page containing that WordPress template. After a short time, Google Analytics will propagate and start receiving data for your site. You can see whether data is being received by a small green tick under the ‘Status’ column in your website’s Google Analytics account.
Please note that this process will need to be repeated for every template you wish to use.
There may be alternative methods of implementation via the dashboard, but this is the method I used to enable Google Analytics tracking on my personal WordPress blog.