osclass / plugin-google_analytics

Plugin for Google analytics
0 stars 3 forks source link

Move the Analytics code to HEADER #1

Open eurobank opened 10 years ago

eurobank commented 10 years ago

I think it is time to update the plugin, so the analytics code is moved to the HEADER of the script, as Google suggests.

https://support.google.com/analytics/answer/1008080?hl=en

Paste your snippet (unaltered, in it’s entirety) into every web page you want to track. Paste it immediately before the closing tag.

If your website uses templates to generate pages, enter it just before the closing tag in the file that contains the the section.

dev-101 commented 10 years ago

Hmm... now I am confused, since last year when I implemented GA code on one website, the advice was to put it immediatelly AFTER opening body tag (so that G gets assured that page is loaded and displayed). Now, it did sound strange to me, but I listened. This is new read for me, but I don't think it makesa huge difference wherever you put it.

edit: I actualy use external php file with google tracking code, so that is the cause of the difference.

eurobank commented 10 years ago

I'm always following what google says about Google products. If google says to put it in the header, why insist to put it in the footer ? I don't get it.

As for the technical part, it sure makes difference because puting it in the header ALWAYS counts the page visit. Puting in the footer it MAY not always count unfinished page views.

dev-101 commented 10 years ago

Yes, I know it makes difference and that was the reason why google wanted it later in the page, so to be sure page actually loaded.

I don't think you need a plugin at all for GA code, simply put the code in head.php or header.php (depends on a theme) between < head > ... < /head > tags and you are good.