Page 1 of 1

Google Analytics JS position

Posted: Wed Mar 12, 2008 7:49 pm
by adamcharnock
Hey Everyone,

I was wondering if there was some ulterior reason for the Google Analytics code (in serendipity_event_google_analytics by kleinerChemiker) being placed at towards the top of the page rather than at the bottom?

I am not 100%, but I think that this will cause some (don't ask which :p ) browsers to run this code before displaying the rest of the page. Google says:
Copy the following code block into every web page you want to track, immediately before the </body> tag.
I have made a minor change to put this code at the bottom if people think that this is a good idea - but if there was a particular reason behind this decision then that is fine.

The (teeny tiny) patch is:

Code: Select all

serendipity_event_google_analytics.php
34c34
<               $propbag->add('event_hooks',   array('frontend_header' => true, 'frontend_display' => true));
---
>               $propbag->add('event_hooks',   array('frontend_footer' => true, 'frontend_display' => true));
235c235
<                               case 'frontend_header':
---
>                               case 'frontend_footer':

Best,

Re: Google Analytics JS position

Posted: Wed Mar 12, 2008 8:07 pm
by garvinhicking
Hi!

I believe there was a reason for this. But I hope Kleinerchemiker reads this here, I know he is still active. If he doesn't catch it here we might need to send him a PM here on the board :)

Regards,
Garvin

Posted: Wed Mar 12, 2008 8:21 pm
by adamcharnock
Hey Garvin,

I have dopped him a quick (but polite :) ) PM. We could always add it is a config option if there is a good reason either way.

Posted: Wed Mar 12, 2008 10:04 pm
by kleinerChemiker
Hi,

thx for the pm.

Yes, there is a reason why the code is in the head. It's necesary to track downloads and external links.
see also: http://www.google.com/support/googleana ... opic=11006

Posted: Wed Mar 12, 2008 10:16 pm
by adamcharnock
Ah, I see. Thank you for clearing this up!

You can go ahead and ignore my patch :p

Best,