Problems if javascript tracker isn't just above the body tag?


(kvr) #1

Hello,

because of the limitations of the cms we are using, I cannot place the tracker code just above the tag.

What are the consequences and possible issues of this?

best regards
– kvr


(vipsoft) #2

Should work, even if you put the tracking code in the head tag.


(holch) #3

[quote=kvr @ Apr 26 2010, 01:26 PM]Hello,

because of the limitations of the cms we are using, I cannot place the tracker code just above the tag.

What are the consequences and possible issues of this?

best regards
– kvr[/quote]

The recommendation to place the code just above the closing body tag is because of performance. Should the server, were Piwik runs be slow or offline, the website would still load.

If you put the code further above, this could lead to the website not loading anymore.

However, be aware that you are measuring different things, depending on where the code is placed.

The further up the code is placed the more page views you will register. Depending on the website it can happen that users already have clicked away from the current page, while the tracking code hasn’t been loaded yet.

With the code on the bottom, you will count only those page views, where the page has been loaded completely or almost completely.