Sunday 26 February 2012

Using Google Analytics in webs.com

The latest version of the Analytics tracking code offers an improved way to track website visitors with Google Analytics. It takes advantage of browser support for asynchronous JavaScript to enhance the speed in which the tracking code is loaded.

Most webmasters will edit the html directly, but webs.com users who take advantage of webs Site Builder templates do not have direct access to the html behind. In this case, the following tracking code must be added to a content box on each of your pages you wish to track. 

Note that you will need to change the 'UA-XXXXX-X' value to your own particular tracking code for that site. 
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXX-X']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>

You can find the tracking code in your Google Analytics account by selecting the account, going to the Home tab, then clicking on the Tools icon at the far right of the header column. See more detailed instructions here
To exclude your own visits from Google analytics tracking, see this article by fritterritter.

2 comments:

  1. Does this actually work? because I'd like to do it and Im not sure how!

    ReplyDelete
  2. Yeah it does, I've got a couple of webs.com sites and they all have google analytics tracking. Just add the html to all of your web pages using Site Builder. Good luck!

    ReplyDelete