Skip to content

Commit

Permalink
fix: Map CouponCode to reserved attributes coupon (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
rmi22186 authored Sep 6, 2023
1 parent 7670d99 commit f7380d4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
3 changes: 3 additions & 0 deletions packages/GA4Client/src/commerce-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ function parseProduct(product) {
case 'Category':
productWithAllAttributes.item_category = product.Category;
break;
case 'CouponCode':
productWithAllAttributes.coupon = product.CouponCode;
break;
case 'Variant':
productWithAllAttributes.item_variant = product.Variant;
break;
Expand Down
27 changes: 13 additions & 14 deletions packages/GA4Client/test/src/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ describe('Google Analytics 4 Event', function () {
value: 100,
items: [
{
coupon_code: 'coupon',
coupon: 'coupon',
item_brand: 'brand',
item_category: 'category',
item_id: 'iphoneSKU',
Expand All @@ -295,7 +295,7 @@ describe('Google Analytics 4 Event', function () {
{
eventMetric1: 'metric1',
journeyType: 'testjourneytype2',
coupon_code: 'coupon',
coupon: 'coupon',
item_brand: 'brand',
item_category: 'category',
item_id: 'iphoneSKU',
Expand Down Expand Up @@ -779,7 +779,7 @@ describe('Google Analytics 4 Event', function () {
{
eventMetric1: 'metric2',
journeyType: 'testjourneytype1',
coupon_code: 'coupon',
coupon: 'coupon',
item_brand: 'brand',
item_category: 'category',
item_id: 'iphoneSKU',
Expand All @@ -793,7 +793,7 @@ describe('Google Analytics 4 Event', function () {
{
eventMetric1: 'metric1',
journeyType: 'testjourneytype2',
coupon_code: 'coupon',
coupon: 'coupon',
item_brand: 'brand',
item_category: 'category',
item_id: 'iphoneSKU',
Expand Down Expand Up @@ -1040,7 +1040,7 @@ describe('Google Analytics 4 Event', function () {
{
eventMetric1: 'metric2',
journeyType: 'testjourneytype1',
coupon_code: 'coupon',
coupon: 'coupon',
item_brand: 'brand',
item_category: 'category',
item_id: 'iphoneSKU',
Expand All @@ -1054,7 +1054,7 @@ describe('Google Analytics 4 Event', function () {
{
eventMetric1: 'metric1',
journeyType: 'testjourneytype2',
coupon_code: 'coupon',
coupon: 'coupon',
item_brand: 'brand',
item_category: 'category',
item_id: 'iphoneSKU',
Expand Down Expand Up @@ -1137,7 +1137,7 @@ describe('Google Analytics 4 Event', function () {
{
eventMetric1: 'metric2',
journeyType: 'testjourneytype1',
coupon_code: 'coupon',
coupon: 'coupon',
item_brand: 'brand',
item_category: 'category',
item_id: 'iphoneSKU',
Expand All @@ -1151,7 +1151,7 @@ describe('Google Analytics 4 Event', function () {
{
eventMetric1: 'metric1',
journeyType: 'testjourneytype2',
coupon_code: 'coupon',
coupon: 'coupon',
item_brand: 'brand',
item_category: 'category',
item_id: 'iphoneSKU',
Expand Down Expand Up @@ -1317,7 +1317,7 @@ describe('Google Analytics 4 Event', function () {
{
eventMetric1: 'metric2',
journeyType: 'testjourneytype1',
coupon_code: 'coupon',
coupon: 'coupon',
item_brand: 'brand',
item_category: 'category',
item_id: 'iphoneSKU',
Expand All @@ -1331,7 +1331,7 @@ describe('Google Analytics 4 Event', function () {
{
eventMetric1: 'metric1',
journeyType: 'testjourneytype2',
coupon_code: 'coupon',
coupon: 'coupon',
item_brand: 'brand',
item_category: 'category',
item_id: 'iphoneSKU',
Expand Down Expand Up @@ -1820,7 +1820,6 @@ describe('Google Analytics 4 Event', function () {
});
});
});

});

describe('identity', function () {
Expand Down Expand Up @@ -2047,7 +2046,7 @@ describe('Google Analytics 4 Event', function () {
eventMetric1: 'metric1',
journeyType: 'testjourneytype2',
test4ever___: 'tester',
coupon_code: 'coupon',
coupon: 'coupon',
item_brand: 'brand',
item_category: 'category',
item_id: 'iphoneSKU',
Expand Down Expand Up @@ -2132,7 +2131,7 @@ describe('Google Analytics 4 Event', function () {
{
eventMetric1: 'metric2',
journeyType: 'testjourneytype1',
coupon_code: 'coupon',
coupon: 'coupon',
item_brand: 'brand',
item_category: 'category',
item_id: 'iphoneSKU',
Expand All @@ -2149,7 +2148,7 @@ describe('Google Analytics 4 Event', function () {
{
eventMetric1: 'metric1',
journeyType: 'testjourneytype2',
coupon_code: 'coupon',
coupon: 'coupon',
item_brand: 'brand',
item_category: 'category',
item_id: 'iphoneSKU',
Expand Down

0 comments on commit f7380d4

Please sign in to comment.