Commit 9a9ffd8a authored by hass's avatar hass
Browse files

Issue #2064389 by hass, ndewhurst: "ga" Object Conflicts with Global

"ga" Function
parent 057567e3
......@@ -10,11 +10,10 @@ $(document).ready(function() {
// Catch the closest surrounding link of a clicked element.
$(event.target).closest("a,area").each(function() {
var ga = Drupal.settings.googleanalytics;
// Expression to check for special links like gotwo.module /go/* links.
var isInternalSpecial = new RegExp("(\/go\/.*)$", "i");
// Expression to check for download links.
var isDownload = new RegExp("\\.(" + ga.trackDownloadExtensions + ")$", "i");
var isDownload = new RegExp("\\.(" + Drupal.settings.google_analytics.trackDownloadExtensions + ")$", "i");
// Is the clicked URL internal?
if (isInternal.test(this.href)) {
......@@ -23,7 +22,7 @@ $(document).ready(function() {
// Do nothing here. The custom event will handle all tracking.
}
// Is download tracking activated and the file extension configured for download tracking?
else if (ga.trackDownload && isDownload.test(this.href)) {
else if (Drupal.settings.google_analytics.trackDownload && isDownload.test(this.href)) {
// Download link clicked.
var extension = isDownload.exec(this.href);
ga("send", "event", "Downloads", extension[1].toUpperCase(), this.href.replace(isInternal, ''));
......@@ -34,12 +33,12 @@ $(document).ready(function() {
}
}
else {
if (ga.trackMailto && $(this).is("a[href^='mailto:'],area[href^='mailto:']")) {
if (Drupal.settings.google_analytics.trackMailto && $(this).is("a[href^='mailto:'],area[href^='mailto:']")) {
// Mailto link clicked.
ga("send", "event", "Mails", "Click", this.href.substring(7));
}
else if (ga.trackOutbound && this.href.match(/^\w+:\/\//i)) {
if (ga.trackDomainMode == 2 && isCrossDomain(this.hostname, ga.trackCrossDomains)) {
else if (Drupal.settings.google_analytics.trackOutbound && this.href.match(/^\w+:\/\//i)) {
if (Drupal.settings.google_analytics.trackDomainMode == 2 && isCrossDomain(this.hostname, Drupal.settings.google_analytics.trackCrossDomains)) {
// Top-level cross domain clicked. document.location is handled by _link internally.
event.preventDefault();
// @todo: unknown upgrade path
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment