Possible Duplicate:
google analytics at head? or end of body?
The google analytics code has to be put before the HEAD tag. Can anyone tell where do i put the ga code if there is no HEAD tag present in my jsp file?
Possible Duplicate:
google analytics at head? or end of body?
The google analytics code has to be put before the HEAD tag. Can anyone tell where do i put the ga code if there is no HEAD tag present in my jsp file?
Google Analytics link to Google Webmaster Tool is easily verified if code is placed in the head.
The argument "is it a pageview if the code fires from a visitor and then they immediately leave" seems a non-argument to me - this should be registered as a bounce. If you place it lower down you are in danger of code not firing and no visit / pageview being initiated.
Further to this in-page analytics, which is a useful view in Google Analytics, is dependent on correct placement as advised by Google Analytics immediately before the closing head tag.
Note that the referenced quote posted by Augustus is in fact old - for the latest Asynchronous tracking code Google Analytics advises code to be in the head http://support.google.com/googleanalytics/bin/answer.py?hl=en&answer=161379
The correct answer here would be to add head tags to your file. You should be using valid html markup for all your pages, and including head tags (even if empty - though certain other tags within head tag are required, depending on what type of document you are serving. Like..title tag and some meta tags...) is part of a validly marked up document. Not to mention that it hurts your SEO efforts not to have it (with relevant info, like aforementioned title and meta tags..).
However if you insist on not having a head tag in your document, you can place the GA code anywhere; in the head tag is just the optimal place - according to some people.
The logic behind putting it higher up is to give it a chance to track, even if a person tries to leave the page before it is done loading (closing the browser, clicking the redirect button, maybe js on the page redirects, etc...).. However, in my experience, I do not really think these are valid reasons for putting the tracking code high up on the page.
In fact, I would argue against tracking hits such as those. My main question/thought about that is...how can you rightfully say a user viewed the page if they immediately left it, even before it was fully loaded? But that's just IMO.
Found answered http://support.google.com/googleanalytics/bin/answer.py?hl=en&answer=55574
here is quotation
I feel the adding the google analytics at the bottom will be more effective as it is a java script.
Its one of the best practice to follow and allowing the website to load faster.