Skip to content

Commit

Permalink
Release 1.1.5
Browse files Browse the repository at this point in the history
Support added for user opt-out and exception tracking.
  • Loading branch information
justinsa committed Dec 19, 2015
1 parent d7b635d commit 414e29d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
41 changes: 37 additions & 4 deletions dist/angular-google-analytics.js
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)
Expand Down Expand Up @@ -30,6 +30,7 @@
debugMode = false,
delayScriptTag = false,
displayFeatures = false,
disableAnalytics = false,
domainName,
ecommerce = false,
enhancedEcommerce = false,
Expand Down Expand Up @@ -153,6 +154,11 @@
return this;
};

this.disableAnalytics = function (val) {
disableAnalytics = !!val;
return this;
};

this.setHybridMobileSupport = function (val) {
hybridMobileSupport = !!val;
return this;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -1041,6 +1070,7 @@
currency: currency,
debugMode: debugMode,
delayScriptTag: delayScriptTag,
disableAnalytics: disableAnalytics,
displayFeatures: displayFeatures,
domainName: domainName,
ecommerce: that._ecommerceEnabled(),
Expand Down Expand Up @@ -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);
},
Expand Down
Loading

0 comments on commit 414e29d

Please sign in to comment.