A call to googleanalytics.trackUrlFragments in document.ready is causing a blocking JavaScript error in some cases. In general the module should not assume that Drupal.settings.googleanalytics is ready at that point because that´s not always the case. In particular this happens when you clear the browser cache and navigate to a second page after loading the website normally and then the error stops until the next time you clear the browser cache.

I propose a small and inocuos change that is to simply move the verification to be done inside the event. The overhead is minimal and it prevents this error from killing unrelated scripts grouped in the same file.

  // Track hash changes as unique pageviews, if this option has been enabled.
  window.onhashchange = function() {
     if (Drupal.settings.googleanalytics.trackUrlFragments) {
      ga("send", {
        "hitType": "pageview",
        "page": location.pathname + location.search + location.hash
      });
    };
  }

Comments

jacmkno created an issue. See original summary.

jacmkno’s picture

Issue summary: View changes
jacmkno’s picture

jacmkno’s picture

Status: Active » Closed (works as designed)

Sorry, my mistake. Nothing important was being broken here and the error seems to have been caused by an ajax call which was delaying the document ready event way beyond normal.