Forum Moderators: DixonJones

Message Too Old, No Replies

Installing Google Analytics (directly before closing body tag?)

         

littlegiant

3:31 pm on May 9, 2008 (gmt 0)

10+ Year Member



Just a quick question about installing the Google Analytics tracking code (new ga version)...

Must it go directly before the closing </body> tag or can it go somewhere in that general area? For example, can I just put it in my website's footer includes file (which precedes the closing body tag in the source code anyway but not directly)?

This would make the installation a whole lot easier. Otherwise, I'll be obliged to go through each and every page on a 150+ page site and install the code manually.

It seems to me that since it's just a Javascript that it should work fine as long as it's in that general area (and before the closing body tag). Somebody correct please if I'm wrong. Thanks.

Philosopher

3:52 pm on May 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



yes, you can put it in your footer file. I do that on a number of sites and the footer is output close to the end body tag, but not directly before it.

I think the reason they way you to put it directly before the last body tag is it will keep it from delaying the rest of your page loading if the GA request takes a bit.

Having it at the end also helps to only count visitors that actually let the page fully load.

littlegiant

3:55 pm on May 9, 2008 (gmt 0)

10+ Year Member



Okay thanks very much!