diff --git a/googleanalytics.debug.js b/googleanalytics.debug.js index 331bc43..3e3ecb6 100644 --- a/googleanalytics.debug.js +++ b/googleanalytics.debug.js @@ -25,12 +25,12 @@ $(document).ready(function() { else if (Drupal.settings.googleanalytics.trackDownload && Drupal.googleanalytics.isDownload(this.href)) { // Download link clicked. console.info("Download url '%s' has been found. Tracked download as extension '%s'.", Drupal.googleanalytics.getPageUrl(this.href), Drupal.googleanalytics.getDownloadExtension(this.href).toUpperCase()); - ga("send", "event", "Downloads", Drupal.googleanalytics.getDownloadExtension(this.href).toUpperCase(), Drupal.googleanalytics.getPageUrl(this.href)); + ga("send", "event", "Downloads", Drupal.googleanalytics.getDownloadExtension(this.href).toUpperCase(), Drupal.googleanalytics.getPageUrl(this.href), { 'transport': 'beacon' }); } else if (Drupal.googleanalytics.isInternalSpecial(this.href)) { // Keep the internal URL for Google Analytics website overlay intact. console.info("Click on internal special link '%s' has been tracked.", Drupal.googleanalytics.getPageUrl(this.href)); - ga("send", "pageview", { "page": Drupal.googleanalytics.getPageUrl(this.href) }); + ga("send", "pageview", { "page": Drupal.googleanalytics.getPageUrl(this.href), 'transport': 'beacon' }); } else { // e.g. anchor in same page or other internal page link @@ -41,13 +41,13 @@ $(document).ready(function() { if (Drupal.settings.googleanalytics.trackMailto && $(this).is("a[href^='mailto:'],area[href^='mailto:']")) { // Mailto link clicked. console.info("Click on e-mail '%s' has been tracked.", this.href.substring(7)); - ga("send", "event", "Mails", "Click", this.href.substring(7)); + ga("send", "event", "Mails", "Click", this.href.substring(7), { 'transport': 'beacon' }); } else if (Drupal.settings.googleanalytics.trackOutbound && this.href.match(/^\w+:\/\//i)) { if (Drupal.settings.googleanalytics.trackDomainMode != 2 || (Drupal.settings.googleanalytics.trackDomainMode == 2 && !Drupal.googleanalytics.isCrossDomain(this.hostname, Drupal.settings.googleanalytics.trackCrossDomains))) { // External link clicked / No top-level cross domain clicked. console.info("Outbound link '%s' has been tracked.", this.href); - ga("send", "event", "Outbound links", "Click", this.href); + ga("send", "event", "Outbound links", "Click", this.href, { 'transport': 'beacon' }); } else { console.info("Internal link '%s' clicked, not tracked.", this.href); diff --git a/googleanalytics.js b/googleanalytics.js index 1eed3c3..977751c 100644 --- a/googleanalytics.js +++ b/googleanalytics.js @@ -21,22 +21,22 @@ $(document).ready(function() { // Is download tracking activated and the file extension configured for download tracking? else if (Drupal.settings.googleanalytics.trackDownload && Drupal.googleanalytics.isDownload(this.href)) { // Download link clicked. - ga("send", "event", "Downloads", Drupal.googleanalytics.getDownloadExtension(this.href).toUpperCase(), Drupal.googleanalytics.getPageUrl(this.href)); + ga("send", "event", "Downloads", Drupal.googleanalytics.getDownloadExtension(this.href).toUpperCase(), Drupal.googleanalytics.getPageUrl(this.href), { 'transport': 'beacon' }); } else if (Drupal.googleanalytics.isInternalSpecial(this.href)) { // Keep the internal URL for Google Analytics website overlay intact. - ga("send", "pageview", { "page": Drupal.googleanalytics.getPageUrl(this.href) }); + ga("send", "pageview", { "page": Drupal.googleanalytics.getPageUrl(this.href), 'transport': 'beacon' }); } } else { if (Drupal.settings.googleanalytics.trackMailto && $(this).is("a[href^='mailto:'],area[href^='mailto:']")) { // Mailto link clicked. - ga("send", "event", "Mails", "Click", this.href.substring(7)); + ga("send", "event", "Mails", "Click", this.href.substring(7), { 'transport': 'beacon' }); } else if (Drupal.settings.googleanalytics.trackOutbound && this.href.match(/^\w+:\/\//i)) { if (Drupal.settings.googleanalytics.trackDomainMode != 2 || (Drupal.settings.googleanalytics.trackDomainMode == 2 && !Drupal.googleanalytics.isCrossDomain(this.hostname, Drupal.settings.googleanalytics.trackCrossDomains))) { // External link clicked / No top-level cross domain clicked. - ga("send", "event", "Outbound links", "Click", this.href); + ga("send", "event", "Outbound links", "Click", this.href, { 'transport': 'beacon' }); } } }