Integrate Google Analytics With Your WordPress Blog

9th June 2010

Integrate Google Analytics With Your WordPress Blog Integrate Google Analytics With Your WordPress Blog

It’s important to keep track of how many people are visiting your website and to monitor some key statistics such as the number of unique visits, the pages most viewed, and the length of time visitors are staying on your site.

Google Analytics is the main tool that is used for this task and does a very thorough job – you can get information on just about everything and really drill down and understand how people are interacting with your website.

In fact, the amount of data it provides can be a little overwhelming if you’re relatively new to statistical applications. However, it’s certainly a great tool and something that you’ll want to be using to track visitors to your WordPress blog.

Quick Tip For iPhone Users – many people prefer using the Analytics App for the iPhone to view Google Analytics data as it’s less overwhelming than the standard web-based version and does a good job of providing you with key data about your website’s traffic.

Once you have created your Google Analytics account there are three primary ways in which you can enable it on your WordPress powered site.

1. Manually add it to your footer.php file

This is relatively quick and easy – copy the code that Google Analytics provides you with and paste it the bottom of your footer.php file (just above the </body> tag).

Save your changes and Google Analytics will be enabled. The only downside to this approach is that the footer.php is a “theme” file which means that if you change your theme you’ll need to update the footer.php file on your new theme.

This can be something that’s very easy to forget to do when changing themes, so bear it in mind when using this approach.

2. Edit the functions.php file

Another separate approach is to edit your functions.php file – add the following code to this file:

<?php
add_action('wp_footer', 'enable_google_analytics');
function enable_google_analytics() { ?>
// Edit Your Google Analytics Code Here
<?php } ?>

Make sure that you add your Google Analytics code in the appropriate place and it will then be integrated with your site and ready to start monitoring traffic.

Again, the main issue with this approach is that the “functions.php” file is a theme specific file. So, as with the footer.php approach, if you decide to change your theme you’ll need to update the functions.php file in your new theme.

3. Use a plugin

One way to get round the issue of editing theme specific files is to use a plugin – there are some useful ones around that do the job such as Google Analytics For WordPress.

The only slight downside to this approach is that you have to add another plugin to your website which adds an additional overhead when the same functionality can be achieved in a just few lines code.

However, if you change themes the plugin should continue to work, so you can set and forget it which is appealing to many people.

In summary, all of the above approaches will work just fine – the one you choose largely depends on your own personal taste. If you change your site’s theme on a regular basis you may want to opt for the plugin approach.

If, on the other hand, you’re unlikely to change your theme in the near future maybe option one or two might be suitable for you.

Enjoy This Post? Please Consider Sharing :-)

  • Twitter
  • StumbleUpon
  • Facebook
  • Digg
  • del.icio.us
  • Reddit
  • Technorati

No Comments

Trackbacks/Pingbacks

  1. June 10th, 2010 at 4:15 pm

    [...] Integrate Google Analytics With Your WordPress Blog [...]