Skip to content

Commit 626a923

Browse files
Added product Id in Ordered Product track event of klaviyo (#736)
* Added product Id in Ordered Product track event of klaviyo * Klaviyo unit test cases added * Change veriable name productId to ProductID as klaviyo description * HGI-394 Test case added --------- Co-authored-by: Ankit Gupta <[email protected]>
1 parent dca45f8 commit 626a923

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

integrations/klaviyo/lib/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ function formatItems(track) {
217217
ProductCategories: [product.category()],
218218
ProductURL: product.proxy('properties.productUrl'),
219219
ImageURL: product.proxy('properties.imageUrl'),
220-
SKU: product.sku()
220+
SKU: product.sku(),
221+
ProductID: product.productId() || product.id()
221222
});
222223

223224
// ensure unique $event_id is associated with each Ordered Product event by combining Order Completed

integrations/klaviyo/test/index.test.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,13 @@ describe('Klaviyo', function() {
322322
ProductCategories: ['Games'],
323323
ProductURL: 'http://www.example.com/path/to/product',
324324
ImageURL: 'http://www.example.com/path/to/product/image.png',
325-
SKU: '45790-32'
325+
SKU: '45790-32',
326+
ProductID: '507f1f77bcf86cd799439011'
326327
}
327328
]);
328329
});
329330

330-
it('should have the correct $event_id for Ordered Product if id passed as product_id', function() {
331+
it('should have correct $event_id for Ordered Product if id passed as product_id', function() {
331332
analytics.track('Completed Order', {
332333
order_id: '50314b8e9bcf000000000000',
333334
total: 30,
@@ -362,7 +363,8 @@ describe('Klaviyo', function() {
362363
ProductCategories: ['Games'],
363364
ProductURL: 'http://www.example.com/path/to/product',
364365
ImageURL: 'http://www.example.com/path/to/product/image.png',
365-
SKU: '45790-32'
366+
SKU: '45790-32',
367+
ProductID: '507f1f77bcf86cd799439011'
366368
}
367369
]);
368370
});

0 commit comments

Comments
 (0)