Why javascript scope option has disapeared ? I want to load google analitycs javascript in the footer as recommended by google.

Comments

hass’s picture

Status: Active » Fixed

No longer recommended in 3.0, see the asyc case for the reasons why the option is gone.

danrasband’s picture

I'm using version 6.x-3.0, and the code is inserted in the footer. I confirmed that it is the asynchronous code, that I'm running the right version of the module, and I ran the database updates, so why is the code still getting placed in the footer?

zet’s picture

This is a funny issue now, danrasband :) I wanted the opposite. :)

Thanks Hass. I didn't knew about that. I haven't used analytics for a while.

BradleyT’s picture

I just downloaded 6.x-3.0 and it's showing in the footer also.

danrasband’s picture

Status: Fixed » Active
hass’s picture

Status: Active » Fixed
izmeez’s picture

I am using the 6.x-3.x-dev version from 2010-10-09 and this is still appearing in the footer.

Thanks,

Izzy

mrgoltstein’s picture

Same issue with 6.x-3.0.

Fix: change line 178 of googleanalytics.module from:
drupal_add_js($script, 'inline', 'footer');
to
drupal_add_js($script, 'inline', 'header');

hass’s picture

No, this doesn't work and please do not confuse people with something you have not tested - see #212560: drupal_add_js in hook_footer does not add JS files and Support for Asynchronous Tracking and the following comments. Search for 'footer' and 'header' for the answer why it is NOT possible to add async to header section in D6.

izmeez’s picture

Should the status of this issue be changed from "fixed" to "postponed" if it is a Drupal 6 limitation?

Thanks,

Izzy

mrgoltstein’s picture

Hass, I presume your argumentation for comment#9 is http://drupal.org/node/648284#comment-3023848. However, anywhere I look @ analytics (even at the page w/the code snippet) it is suggested to put the code just before the closing , which seems to work fine with this change. The snippet is displayed in the HTML at the proper place, and results are showing up in Analytics as expected.

Am I missing something?

hass’s picture

Again, you cannot add JS to header in hook_footer() in D6. Garbor also confirmed this is too late!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

babbage’s picture

Title: javascript in the footer » Document that module using asynchronous javascript but not able to correctly load code in header
Status: Closed (fixed) » Active

Doesn't this warrant specific documentation? I've wasted a fair bit of time today trying to debug why despite updating to 3.0, the Chrome plugin reported asynchronous code was not being used, and Google Webmaster tools were unable to verify the site using the "Link to your Google Analytics account", which specifies:
"You can use this option if your site already has a Google Analytics tracking code that uses the asynchronous snippet." Presumably what they mean is that you have to have a *configured as per the guidelines* asynchronous snippet, which this module is not able to provide. It'd be nice to see that front and centre on the documentation for this module, if my interpretation of this is correct.

hass’s picture

Uncheck local caching and clear your caches! Validate again - must work.

babbage’s picture

Hass, I'm not sure what you're saying. Are you saying that this will result in the ga.js code being placed in the header? Following that procedure (I did have local caching turned on) did not result in any change for me. ga.js still loads in the footer of the page.

babbage’s picture

Upgraded to latest 3.x-dev as I was running 3.0: no change. JS still loaded in footer. Isn't that what you were saying in #12 hass?

hass’s picture

No - local caching makes the tracker validation failing. The tool do not understand the code changes. Could you read the description next to the checkbox VERY CAREFULLY first, please?

hass’s picture

Status: Active » Closed (fixed)

Nobody provided a patch within the last 2 months that adds some comments to readme. Closing as there seems to be no interrest to add this docs to the module.

pasqualle’s picture

Status: Closed (fixed) » Active

there are 2 kinds of validation:
google analytics validation: this works
google webmaster tools validation: this does not work afaik. can you confirm or deny?

hass’s picture

Status: Active » Closed (fixed)

Turn of local caching

pasqualle’s picture

it is turned off

hass’s picture

OT and I don't know what webmaster tools are doing and why they are broken. Don't worry, the code is correct.

EvanDonovan’s picture

Version: 6.x-3.0 » 6.x-3.x-dev
Status: Closed (fixed) » Fixed

Just wanted to let everyone know I updated the troubleshooting page to include this info, as well as some other issues that can occur on upgrade from 2.x to 3.x. If someone wants to confirm that everything I stated is accurate, that would be great.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

seandunaway’s picture

Status: Closed (fixed) » Closed (duplicate)

Just for history, marking as duplicate of #1023384: Moving ga.js to <head>.

As of now it still does not validate correctly with Google Webmaster Tools with or without local caching. Google wants it in the header.

Potential fix that needs testing in the duplicate issue.