Google Analytics Code Position Top or Bottom of Page coding

We get asked about the Google analytics code on many occasions. Why is it at the bottom of the page on some sites and at the top of the page on others?

Well the answer from Google:-

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. With this version of the tracking code, you can also place the Analytics snippet higher in the page without delaying subsequent content from rendering.

Although asynchronous tracking uses a different Analytics snippet and a different syntax for tracking calls than the traditional snippet, it supports the exact same tracking customizations as the traditional snippet. In fact, the asynchronous tracking syntax is also more flexible than the traditional snippet. For more details, see the Usage Guide.

The Snippet

The Analytics snippet is a small piece of JavaScript code that you paste into your pages. It activates Google Analytics tracking by inserting ga.js into the page. To use this on your pages, copy the code snippet below, replacing UA-XXXXX-X with your web property ID. If you need to do more than basic page tracking, see the tracking reference for a list of methods available in the API and see the Usage Guide for details on using the asynchronous syntax. For step-by-step instructions on setting up tracking, see the Help Center article on setting up tracking.

<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>

The snippet above represents the minimum configuration needed to track a page asynchronously. It uses _setAccount to set the page’s web property ID and then calls _trackPageview to send the tracking data back to the Google Analytics servers.

Important: If you are updating your pages from the traditional snippet to the latest, asynchronous version, you should remove the existing tracking snippet first. We do not recommend using both snippets together on the same page.

Migration Instructions

This section covers how to migrate to the asynchronous snippet on pages that currently use traditional tracking with ga.js. If you are using the urchin.js snippet, please see the Asynchronous Migration Examples for help migrating your customizations from urchin.js to asynchronous tracking.

To convert your pages to use the asynchronous snippet, follow these steps:

  1. Remove your existing tracking code snippet and any customizations you have made.To reduce errors, we recommend that you remove the existing tracking code snippet from the include file or mechanism that injects it into your web pages. You can paste your existing tracking code snippet in a text file to keep track of any customized methods you use.
  2. Insert the asynchronous snippet at the bottom of the <head> section of your pages, after any other scripts your page or template might use.One of the main advantages of the asynchronous snippet is that you can position it at the top of the HTML document. This increases the likelihood that the tracking beacon will be sent before the user leaves the page. We’ve determined that on most pages, the optimal location for the asynchronous snippet is at the bottom of the <head> section, just before the closing </head> tag.
  3. Modify the _setAccount method with your web property ID.
    For more information on web property IDs, see the “Web Property” section in the Accounts and Profiles document.
  4. Add your customizations back in using the asynchronous syntax. The Usage Guide and Migration Examples pages provide many examples of these conversions.

Note: To ensure the most streamlined operation of the asynchronous snippet with respect to other scripts, we recommend you place other scripts in your site in one of these ways:

  • before the tracking code snippet in the <head> section of your HTML
  • after both the tracking code snippet and all page content (e.g. at the bottom of the HTML body)

If that isn’t an option, you can still put the asynchronous snippet at the bottom of the page. You can also split your snippet to retain some of the benefits of asynchronous tracking.

A Quarter Of

Do you remember in the good old days when it used to A Quarter Of your favourite penny sweets. Well now go to Sweet Heaven online and buy A Quarter Of sweets today in 2010.

Corporate Chauffeurs

Corporate chauffeurs are hard to find, well reliable and professional corporate chauffeurs are anyway.

We use a company called Babington Executive Transfers and they are very professional.

If you are looking for corporate chauffeurs then why not give them a try.

Womens Fashion Clothing

Ladies Fashion Clothing from La Bels in Hockey Heath.

SEO Company

Finding an SEO company is not hard. but how do you know that they can deliver what is that they say they can.

Well imagine that you were a Birmingham based business and you wanted SEO services you may search in Google for Birmingham SEO services or Birmingham SEO company. You would hope that the SEO company that is based in Birmingham is top of Google for the search you have chosen.

Then you may want to check out a few clients site and see how they have done compared to other SEO companies.

You may see a portfolio site like a Sweet Shop and think to yourself well the word “Sweets” must be a tough keyword to be on the first page of Google for.

I would suggest trying this and then contact Chameleon Web Services.

Out Source SEO Services

Chameleon has been providing outsourced SEO services for UK based clients and made many happy clients and as part of our networking of happy SEO customers we are winning more and more projects.

Out Source SEO

It seems everyone is looking for  Outsource SEO. We help companies deliver better results without adding head count to a business and in the current climate this can really help. SEO companies from all over the world get in touch with us every day asking us if we require SEO so we realise that it is not difficult to find an SEO company.

SEO Success

But an SEO company you can trust! is hard to find. That’s why Chameleon has so many happy clients that are more than happy to recommend us.

Just take a look at a few clients and look for them online. The proof is the results we can show you.

Chameleon Web Services New Website

One of the biggest problem with running a successfull business is that there is not enough time in the day spare to work on your own projects.

Well we are coming to the end of 2010 and Chameleon Web Services needs a new website so we are working on this now to get completed in the near future.