Skip to content
This repository was archived by the owner on Aug 14, 2019. It is now read-only.

Commit fbfff30

Browse files
committed
Add custom dimensions and metrics for promotion viewed EE event; update associated test.
1 parent db351ee commit fbfff30

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

lib/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,7 @@ GA.prototype.productClickedEnhanced = function(track) {
885885
GA.prototype.promotionViewedEnhanced = function(track) {
886886
var props = track.properties();
887887
var self = this;
888+
var opts = this.options;
888889

889890
this.loadEnhancedEcommerce(track);
890891
window.ga(self._trackerName + 'ec:addPromo', {
@@ -893,7 +894,7 @@ GA.prototype.promotionViewedEnhanced = function(track) {
893894
creative: props.creative,
894895
position: props.position
895896
});
896-
this.pushEnhancedEcommerce(track);
897+
this.pushEnhancedEcommerce(track, opts, self._trackerName);
897898
};
898899

899900
/**
@@ -908,6 +909,7 @@ GA.prototype.promotionViewedEnhanced = function(track) {
908909
GA.prototype.promotionClickedEnhanced = function(track) {
909910
var props = track.properties();
910911
var self = this;
912+
var opts = this.options;
911913

912914
this.loadEnhancedEcommerce(track);
913915
window.ga(self._trackerName + 'ec:addPromo', {
@@ -917,7 +919,7 @@ GA.prototype.promotionClickedEnhanced = function(track) {
917919
position: props.position
918920
});
919921
window.ga(self._trackerName + 'ec:setAction', 'promo_click', {});
920-
this.pushEnhancedEcommerce(track);
922+
this.pushEnhancedEcommerce(track, opts, self._trackerName);
921923
};
922924

923925
/**

test/index.test.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,12 +1126,18 @@ describe('Google Analytics', function() {
11261126
});
11271127

11281128
it('should send promotion viewed data', function() {
1129+
ga.options.setAllMappedProps = false;
1130+
ga.options.dimensions = { testDimension: 'dimension1' };
1131+
ga.options.metrics = { testMetric: 'metric1' };
1132+
11291133
analytics.track('promotion viewed', {
11301134
currency: 'CAD',
11311135
promotion_id: 'PROMO_1234',
11321136
name: 'Summer Sale',
11331137
creative: 'summer_banner2',
1134-
position: 'banner_slot1'
1138+
position: 'banner_slot1',
1139+
testDimension: true,
1140+
testMetric: true
11351141
});
11361142

11371143
analytics.assert(window.ga.args.length === 4);
@@ -1142,7 +1148,11 @@ describe('Google Analytics', function() {
11421148
creative: 'summer_banner2',
11431149
position: 'banner_slot1'
11441150
}]);
1145-
analytics.deepEqual(toArray(window.ga.args[3]), ['send', 'event', 'EnhancedEcommerce', 'promotion viewed', { nonInteraction: 1 }]);
1151+
analytics.deepEqual(toArray(window.ga.args[3]), ['send', 'event', 'EnhancedEcommerce', 'promotion viewed', {
1152+
dimension1: 'true',
1153+
metric1: 'true',
1154+
nonInteraction: 1
1155+
}]);
11461156
});
11471157

11481158
it('should send promotion clicked data', function() {

0 commit comments

Comments
 (0)