Why javascript scope option has disapeared ? I want to load google analitycs javascript in the footer as recommended by google.
Why javascript scope option has disapeared ? I want to load google analitycs javascript in the footer as recommended by google.
Comments
Comment #1
hass commentedNo longer recommended in 3.0, see the asyc case for the reasons why the option is gone.
Comment #2
danrasband commentedI'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?
Comment #3
zet commentedThis 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.
Comment #4
BradleyT commentedI just downloaded 6.x-3.0 and it's showing in the footer also.
Comment #5
danrasband commentedComment #6
hass commentedComment #7
izmeez commentedI am using the 6.x-3.x-dev version from 2010-10-09 and this is still appearing in the footer.
Thanks,
Izzy
Comment #8
mrgoltstein commentedSame 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');Comment #9
hass commentedNo, 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.
Comment #10
izmeez commentedShould the status of this issue be changed from "fixed" to "postponed" if it is a Drupal 6 limitation?
Thanks,
Izzy
Comment #11
mrgoltstein commentedHass, 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?
Comment #12
hass commentedAgain, you cannot add JS to header in hook_footer() in D6. Garbor also confirmed this is too late!
Comment #14
babbage commentedDoesn'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.
Comment #15
hass commentedUncheck local caching and clear your caches! Validate again - must work.
Comment #16
babbage commentedHass, 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.
Comment #17
babbage commentedUpgraded 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?
Comment #18
hass commentedNo - 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?
Comment #19
hass commentedNobody 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.
Comment #20
pasquallethere are 2 kinds of validation:
google analytics validation: this works
google webmaster tools validation: this does not work afaik. can you confirm or deny?
Comment #21
hass commentedTurn of local caching
Comment #22
pasqualleit is turned off
Comment #23
hass commentedOT and I don't know what webmaster tools are doing and why they are broken. Don't worry, the code is correct.
Comment #24
EvanDonovan commentedJust 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.
Comment #26
seandunaway commentedJust 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.