Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello everyone,
First, this is a WONDERFUL module, thank you for all your hard work.
Second, Google now recommends inserting a try/catch around the google analytics code, per the specification on this page.
http://code.google.com/apis/analytics/docs/gaTrackingOverview.html
Note the try/catch wrapping in the sample, below. I'm wondering if we could add this try/catch block into the module so it uses Google's recommendation.
Thanks!
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try{
var pageTracker = _gat._getTracker("UA-xxxxxx-x");
pageTracker._trackPageview();
} catch(err) {}</script>
Comments
Comment #1
hass CreditAttribution: hass commentedThank you very much for this hint. This seems to be a *very* new update to this documentation pages... As it's an official recommendation now - I will add this.
Comment #2
trumpcar CreditAttribution: trumpcar commentedThank you for the quick reply and action. Please let me know where I could grab and test. :)
Comment #3
hass CreditAttribution: hass commentedComment #4
trumpcar CreditAttribution: trumpcar commentedSo quick.. thanks team for making these changes so quickly. I just tested and it looks great.
Comment #5
hass CreditAttribution: hass commentedUps, I missed the onclick tracking in googleanalytics.js...
Comment #6
Tiaan CreditAttribution: Tiaan commentedIn addition to the remaining update on the "googleanalytics.js" file, you might also want to change the code for the "segmentation variable" in the "googleanalytics.module" file. My own patch a while back looked something like the following for the two files, but I haven't verified the "onclick tracking" yet...
Comment #7
hass CreditAttribution: hass commentedFixed the JS files.