-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support added for user opt-out and exception tracking.
- Loading branch information
Showing
3 changed files
with
40 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/** | ||
* Angular Google Analytics - Easy tracking for your AngularJS application | ||
* @version v1.1.4 - 2015-12-11 | ||
* @version v1.1.5 - 2015-12-19 | ||
* @link http://github.com/revolunet/angular-google-analytics | ||
* @author Julien Bouquillon <[email protected]> (https://github.com/revolunet) | ||
* @contributors Julien Bouquillon (https://github.com/revolunet),Justin Saunders (https://github.com/justinsa),Chris Esplin (https://github.com/deltaepsilon),Adam Misiorny (https://github.com/adam187) | ||
|
@@ -30,6 +30,7 @@ | |
debugMode = false, | ||
delayScriptTag = false, | ||
displayFeatures = false, | ||
disableAnalytics = false, | ||
domainName, | ||
ecommerce = false, | ||
enhancedEcommerce = false, | ||
|
@@ -153,6 +154,11 @@ | |
return this; | ||
}; | ||
|
||
this.disableAnalytics = function (val) { | ||
disableAnalytics = !!val; | ||
return this; | ||
}; | ||
|
||
this.setHybridMobileSupport = function (val) { | ||
hybridMobileSupport = !!val; | ||
return this; | ||
|
@@ -380,6 +386,11 @@ | |
return; | ||
} | ||
|
||
if (disableAnalytics === true) { | ||
that._log('info', 'Analytics disabled: ' + accounts[0].tracker); | ||
$window['ga-disable-' + accounts[0].tracker] = true; | ||
} | ||
|
||
_gaq('_setAccount', accounts[0].tracker); | ||
if(domainName) { | ||
_gaq('_setDomainName', domainName); | ||
|
@@ -430,6 +441,13 @@ | |
return; | ||
} | ||
|
||
if (disableAnalytics === true) { | ||
accounts.forEach(function (trackerObj) { | ||
that._log('info', 'Analytics disabled: ' + trackerObj.tracker); | ||
$window['ga-disable-' + trackerObj.tracker] = true; | ||
}); | ||
} | ||
|
||
var document = $document[0]; | ||
var protocol = hybridMobileSupport === true ? 'https:' : ''; | ||
var scriptSource = protocol + '//www.google-analytics.com/' + (debugMode ? 'analytics_debug.js' : 'analytics.js'); | ||
|
@@ -993,7 +1011,7 @@ | |
* https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#customs | ||
* @param name (Required) | ||
* @param value (Required) | ||
* @param trackerName (Not Required) | ||
* @param trackerName (Optional) | ||
* @private | ||
*/ | ||
this._set = function (name, value, trackerName) { | ||
|
@@ -1007,13 +1025,24 @@ | |
* @param timingCategory (Required): A string for categorizing all user timing variables into logical groups(e.g jQuery). | ||
* @param timingVar (Required): A string to identify the variable being recorded(e.g. JavaScript Load). | ||
* @param timingValue (Required): The number of milliseconds in elapsed time to report to Google Analytics(e.g. 20). | ||
* @param timingLabel (Not Required): A string that can be used to add flexibility in visualizing user timings in the reports(e.g. Google CDN). | ||
* @param timingLabel (Optional): A string that can be used to add flexibility in visualizing user timings in the reports(e.g. Google CDN). | ||
* @private | ||
*/ | ||
this._trackTimings = function (timingCategory, timingVar, timingValue, timingLabel) { | ||
this._send('timing', timingCategory, timingVar, timingValue, timingLabel); | ||
}; | ||
|
||
/** | ||
* Exception tracking | ||
* https://developers.google.com/analytics/devguides/collection/analyticsjs/exceptions | ||
* @param description (Optional): A description of the exception. | ||
* @param isFatal (Optional): true if the exception was fatal, false otherwise. | ||
* @private | ||
*/ | ||
this._trackException = function (description, isFatal) { | ||
this._send('exception', { exDescription: description, exFatal: !!isFatal}); | ||
}; | ||
|
||
// creates the Google Analytics tracker | ||
if (!delayScriptTag) { | ||
if (analyticsJS) { | ||
|
@@ -1041,6 +1070,7 @@ | |
currency: currency, | ||
debugMode: debugMode, | ||
delayScriptTag: delayScriptTag, | ||
disableAnalytics: disableAnalytics, | ||
displayFeatures: displayFeatures, | ||
domainName: domainName, | ||
ecommerce: that._ecommerceEnabled(), | ||
|
@@ -1134,9 +1164,12 @@ | |
trackTimings: function (timingCategory, timingVar, timingValue, timingLabel) { | ||
that._trackTimings.apply(that, arguments); | ||
}, | ||
trackTransaction: function (transactionId, affiliation, revenue, tax, shipping, coupon, list, step, option){ | ||
trackTransaction: function (transactionId, affiliation, revenue, tax, shipping, coupon, list, step, option) { | ||
that._trackTransaction.apply(that, arguments); | ||
}, | ||
trackException: function (description, isFatal) { | ||
that._trackException.apply(that, arguments); | ||
}, | ||
setAction: function (action, obj) { | ||
that._setAction.apply(that, arguments); | ||
}, | ||
|
Oops, something went wrong.