Skip to content

Commit 2604384

Browse files
authored
[STRATCONN] 2841 Created mapping for Segment message id to pinterest event id (#783)
* mapMessageIdToEventId settings added * Removed typo error * Changed in test case * added unit test case and mapped segment msgId as Pinterest event_id * Change in unit test case
1 parent 78627f8 commit 2604384

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

integrations/pinterest-tag/lib/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ var Pinterest = (module.exports = integration('Pinterest Tag')
1616
.option('tid', '')
1717
.option('pinterestCustomProperties', [])
1818
.option('useEnhancedMatchLoad', false)
19+
.option('mapMessageIdToEventId', false)
1920
.mapping('pinterestEventMapping')
2021
.tag('<script src="https://s.pinimg.com/ct/core.js"></script>'));
2122

@@ -132,6 +133,10 @@ Pinterest.prototype.createPropertyMapping = function() {
132133
quantity: 'product_quantity',
133134
brand: 'product_brand'
134135
};
136+
137+
if(this.options.mapMessageIdToEventId){
138+
this.propertyMap.messageId = 'event_id';
139+
}
135140
};
136141

137142
/**
@@ -184,6 +189,7 @@ Pinterest.prototype.generatePropertiesObject = function(track) {
184189

185190
// Finally, add in any custom properties defined by the user.
186191
var customProps = this.options.pinterestCustomProperties;
192+
187193
for (var j = 0; j < customProps.length; j++) {
188194
var customProperty = customProps[j];
189195
trackValue = track.proxy('properties.' + customProperty);

integrations/pinterest-tag/test/index.test.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ describe('Pinterest', function() {
1717
'User Signed Up': 'Signup'
1818
},
1919
pinterestCustomProperties: ['custom_prop'],
20-
useEnhancedMatchLoad: false
20+
useEnhancedMatchLoad: false,
21+
mapMessageIdToEventId: true
2122
};
2223

2324
beforeEach(function() {
@@ -44,6 +45,7 @@ describe('Pinterest', function() {
4445
.option('pinterestCustomProperties', [])
4546
.option('tid', '')
4647
.option('useEnhancedMatchLoad', false)
48+
.option('mapMessageIdToEventId', false)
4749
);
4850
});
4951

@@ -92,5 +94,24 @@ describe('Pinterest', function() {
9294
});
9395
});
9496
});
97+
98+
describe('#track', function() {
99+
beforeEach(function() {
100+
analytics.spy(window, 'pintrk');
101+
});
102+
103+
it('should set Segment messageId as Pinterest Evnet Id', function() {
104+
analytics.track('Order Completed', {
105+
currency: 'SGD',
106+
value: 10.0,
107+
messageId: 'testing5671'
108+
});
109+
analytics.called(window.pintrk, 'track', 'Checkout', {
110+
value: 10.0,
111+
currency: 'SGD',
112+
event_id: 'testing5671'
113+
});
114+
});
115+
});
95116
});
96117
});

0 commit comments

Comments
 (0)