Skip to content

Commit

Permalink
Merge pull request #58 from sweetkat/master
Browse files Browse the repository at this point in the history
Added a setting to disable eventTracking/pageTracking
  • Loading branch information
timelf123 authored Jul 21, 2016
2 parents 029e53a + cfc615f commit 1c91403
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/angulartics-ga.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ angular.module('angulartics.google.analytics', ['angulartics'])
// Set the default settings for this module
$analyticsProvider.settings.ga = {
additionalAccountNames: undefined,
disableEventTracking: null,
disablePageTracking: null,
userId: null
};

Expand All @@ -36,6 +38,10 @@ angular.module('angulartics.google.analytics', ['angulartics'])
}

$analyticsProvider.registerPageTrack(function (path) {

// Do nothing if page tracking is disabled
if ($analyticsProvider.settings.ga.disablePageTracking) return;

if (window._gaq) {
_gaq.push(['_trackPageview', path]);
angular.forEach($analyticsProvider.settings.ga.additionalAccountNames, function (accountName){
Expand Down Expand Up @@ -68,6 +74,9 @@ angular.module('angulartics.google.analytics', ['angulartics'])

function eventTrack (action, properties) {

// Do nothing if event tracking is disabled
if ($analyticsProvider.settings.ga.disableEventTracking) return;

// Google Analytics requires an Event Category
if (!properties || !properties.category) {
properties = properties || {};
Expand Down

0 comments on commit 1c91403

Please sign in to comment.