Google Analytics - can I place a script in the footer?

I want to add Google Analytics to our website and read some conflicting information on where to put the script tag.

Google says to put it before the closing tag </ head>: http://code.google.com/apis/analytics/docs/tracking/asyncTracking.html

As our site is designed, this will mean editing each page. This is not a big deal if I need to do this, however our site also uses header and footer files.

These header and footer files have HTML code and they fall into the tags <body>even </body>after the page loads.

It would be much easier to add a script to the header or footer file. I would just insert it there once, and it will serve the code on each page.

My question is: can I do this? Can I move the script fragment inside the footer even though it is not up to the tag </head>that Google offers?

Am I asking for problems if I do this?

Thank!!

+5
source share
6 answers

You can.

, " " (.. </body>), DOM ( script), script. , script DOM, ( ).

, , , script , , - , w371 > .

, Google <head>, , , , , .

+17

. :. Firefox IE . , , . , , - , . , . , , , , , , .

+2

, , , . , , .

+1

, ( WordPress, ). , JS html ( < /body>), .

+1

, . script ; <head>, , document.ready. , . , .

0

, , , .

f you have a header and footer file, why not just add your own Google Analytics code to it? Unless, of course, each page has a unique footer / header page. Then I recommend you take a look at MVC .

0
source

All Articles