Error Pagetracker
Contents |
that make connections all over the world. Join today
Google Analytics Code Example
Download & Extend Drupal Core Distributions Modules Themes Drupal google analytics javascript code tweaksIssues JavaScript error: pageTracker not defined even with Google Analytics turned off Closed
Google Analytics Tracking
(fixed)Project:Drupal tweaksVersion:6.x-1.x-devComponent:Drupal TweaksPriority:NormalCategory:Bug reportAssigned:UnassignedReporter:RetrofitCoderCreated:October 17, 2010 - 05:12Updated:November 1, 2010 - 13:40 Log in or register to update this issue Jump to:Most google analytics javascript api recent attachment Even with Google Analytics turned off, a JS error for pageTacker not defined is thrown when navigating the Drupal Tweaks admin pages. A script block is inserted into the DOM containing pageTracker._trackPageview(location.pathname);. This is because it falls outside the check for the setting _gaq push _trackpageview for using Google Analytics: variable_get('drupal_tweaks_settings_stats_activated', TRUE) ? drupal_add_js(' 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")); var pageTracker; setTimeout("startGA();", 500); function startGA() { try { var pageTracker = _gat._getTracker("UA-948811-17"); pageTracker._setDomainName("none"); pageTracker._setAllowLinker(true); pageTracker._trackPageview(); } catch(err) {} } ', 'inline') : NULL; // <- End of ternary operator for variable_get() drupal_add_js('pageTracker._trackPageview(location.pathname);', 'inline'); // <- Always displays Files: CommentFileSizeAuthor #1 drupal-tweaks-ga-js-error-943902-1.patch1.86 KBRetrofitCoder Comments Comment #1 RetrofitCoder CreditAttribution: RetrofitCoder commented October 17, 2010 at 5:59am Status: Active » Needs review FileSize drupal-tweaks-ga-js-error-943902-1.patch1.86 KB Patch to fix Google Analytics JS errors. Changes that were made: Moved JS for pageTracker._trackPageview(location.pathname); inside the variable_get() check. Removed wrapper function startGA() and setTimeout() function. The setTimeout() function is set for half a second, which allows the script block to finish an
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us
_gaq Is Not Defined
Learn more about Stack Overflow the company Business Learn more about hiring developers ga create or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack
Google Analytics Tracking Code Generator
Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Uncaught ReferenceError: pageTracker is not defined up vote https://www.drupal.org/node/943902 0 down vote favorite You'll have to forgive me on this one. I understand that the issue is probably very simple, but I'm not a JS coder and am only just starting to get to grips with jQuery. So I have a jQuery Ajax call in $(document).ready: $('#newesttab').click(function() { $('li').removeClass('selectedtab'); $('#newesttab').addClass('selectedtab'); $('#col2').removeClass('featuredcol topratedcol').addClass('newestcol'); $("#ajaxresults").fadeOut("slow", function() { $.ajax({ url: "", success: function(msg) { $('#ajaxresults').html(msg); $("#ajaxresults").fadeIn("fast"); http://stackoverflow.com/questions/3174636/uncaught-referenceerror-pagetracker-is-not-defined pageTracker._trackPageview('/code/newest/ajax'); } }) }); }); So basically when #newesttab is clicked, it does a bit of mumbo-jumbo with some Clases & IDs, fades stuff out, then loads some data from an Ajax CodeIgniter function. On success, the div #ajaxresults is filled with the data, fades in - and finally, you'll see this line: pageTracker._trackPageview('/code/newest/ajax'); All that does is check if I'm not on MAMP localhost so as to not get funky data in Analytics. If not, I call Google Analytic's pageTracker thingy to track the URL code/newest/ajax so it appears in my Analytics despite the page being called via Ajax. That's correct, right? Well Chrome's console shows me this error: Uncaught ReferenceError: pageTracker is not defined The part I don't understand, is that because this code is in (document).ready surely it should only fire when the entire document has loaded? And that means, therefore, that the Google Analytics Asynchronous snippet has loaded before my