Skip to content

Commit

Permalink
bump version 0.0.17
Browse files Browse the repository at this point in the history
  • Loading branch information
revolunet committed Jul 9, 2015
1 parent d4aafc1 commit afcf026
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "revolunet",
"name": "angular-google-analytics",
"description": "Easy Analytics for your AngularJS application",
"version": "0.0.15",
"version": "0.0.17",
"homepage": "https://github.com/revolunet/angular-google-analytics",
"repository": {
"type": "git",
Expand Down
39 changes: 32 additions & 7 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 v0.0.15 - 2015-04-27
* @version v0.0.17 - 2015-07-09
* @link http://github.com/revolunet/angular-google-analytics
* @author Julien Bouquillon <[email protected]>
* @license MIT License, http://www.opensource.org/licenses/MIT
Expand Down Expand Up @@ -133,6 +133,28 @@ angular.module('angular-google-analytics', [])
return removeRegExp ? url.replace(removeRegExp, '') : url;
};

var getUtmParams = function () {
var utmToCampaignVar = {
utm_source: 'campaignSource',
utm_medium: 'campaignMedium',
utm_term: 'campaignTerm',
utm_content: 'campaignContent',
utm_campaign: 'campaignName'
};
var object = {};

angular.forEach($location.search(), function (value, key) {
var campaignVar = utmToCampaignVar[key];

if (angular.isDefined(campaignVar)) {
object[campaignVar] = value;
}

});

return object;
};

/**
* Private Methods
*/
Expand Down Expand Up @@ -210,7 +232,7 @@ angular.module('angular-google-analytics', [])
ga.src = gaSrc;
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})(gaSrc);

return created = true;
};

Expand Down Expand Up @@ -345,6 +367,7 @@ angular.module('angular-google-analytics', [])
'page': trackPrefix + url,
'title': title
};
angular.extend(opt_fieldObject, getUtmParams());
if (angular.isObject(custom)) {
angular.extend(opt_fieldObject, custom);
}
Expand Down Expand Up @@ -668,7 +691,6 @@ angular.module('angular-google-analytics', [])
*/
this._trackTransaction = function (transactionId, affiliation, revenue, tax, shipping, coupon, list, step, option) {
this._setAction('purchase', this._getActionFieldObject(transactionId, affiliation, revenue, tax, shipping, coupon, list, step, option));
this._pageView();
};

/**
Expand All @@ -679,7 +701,6 @@ angular.module('angular-google-analytics', [])
*/
this._trackRefund = function (transactionId) {
this._setAction('refund', this._getActionFieldObject(transactionId));
this._pageView();
};

/**
Expand All @@ -691,7 +712,6 @@ angular.module('angular-google-analytics', [])
*/
this._trackCheckOut = function (step, option) {
this._setAction('checkout', this._getActionFieldObject(null, null, null, null, null, null, null, step, option));
this._pageView();
};

/**
Expand Down Expand Up @@ -898,10 +918,15 @@ angular.module('angular-google-analytics', [])
return {
restrict: 'A',
link: function (scope, element, attrs) {
var options = $parse(attrs.gaTrackEvent)(scope);
var options = $parse(attrs.gaTrackEvent);
element.bind('click', function () {
if(attrs.gaTrackEventIf){
if(!scope.$eval(attrs.gaTrackEventIf)){
return; // Cancel this event if we don't pass the ga-track-event-if condition
}
}
if (options.length > 1) {
Analytics.trackEvent.apply(Analytics, options);
Analytics.trackEvent.apply(Analytics, options(scope));
}
});
}
Expand Down
Loading

0 comments on commit afcf026

Please sign in to comment.