Google Analytics JS position

Discussion corner for Developers of Serendipity.
Post Reply
adamcharnock
Regular
Posts: 22
Joined: Sat Mar 08, 2008 1:02 am
Location: London, England
Contact:

Google Analytics JS position

Post 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,
Adam Charnock
Did I help you? You could link to my
blog or leave a comment: http://porteightyeight.com
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Google Analytics JS position

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
adamcharnock
Regular
Posts: 22
Joined: Sat Mar 08, 2008 1:02 am
Location: London, England
Contact:

Post 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.
Adam Charnock
Did I help you? You could link to my
blog or leave a comment: http://porteightyeight.com
kleinerChemiker
Regular
Posts: 765
Joined: Tue Oct 17, 2006 2:36 pm
Location: Vienna/Austria
Contact:

Post 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
adamcharnock
Regular
Posts: 22
Joined: Sat Mar 08, 2008 1:02 am
Location: London, England
Contact:

Post by adamcharnock »

Ah, I see. Thank you for clearing this up!

You can go ahead and ignore my patch :p

Best,
Adam Charnock
Did I help you? You could link to my
blog or leave a comment: http://porteightyeight.com
Post Reply