Skip to content

Commit

Permalink
fix: include measurement Id as event param
Browse files Browse the repository at this point in the history
  • Loading branch information
mmustafa-tse committed Mar 4, 2024
1 parent 1cd142a commit a9d6273
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
33 changes: 18 additions & 15 deletions packages/GA4Client/src/commerce-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,17 @@ CommerceHandler.prototype.logCheckoutOptionEvent = function (
};

CommerceHandler.prototype.logPromotionEvent = function (event) {
var ga4CommerceEventParameters;
var self = this;
try {
var ga4CommerceEventParameters;
event.PromotionAction.PromotionList.forEach(function (promotion) {
ga4CommerceEventParameters = buildPromotion(promotion);

self.sendCommerceEventToGA4(
mapGA4EcommerceEventName(event),
ga4CommerceEventParameters
);
return true;
});
} catch (error) {
console.error(
Expand All @@ -222,22 +229,25 @@ CommerceHandler.prototype.logPromotionEvent = function (event) {
);
return false;
}

this.sendCommerceEventToGA4(
mapGA4EcommerceEventName(event),
ga4CommerceEventParameters
);
return true;
};

CommerceHandler.prototype.logImpressionEvent = function (event, affiliation) {
var ga4CommerceEventParameters;
var self = this;
try {
var ga4CommerceEventParameters;
event.ProductImpressions.forEach(function (impression) {
ga4CommerceEventParameters = parseImpression(
impression,
affiliation
);


self.sendCommerceEventToGA4(
mapGA4EcommerceEventName(event),
ga4CommerceEventParameters
);

return true;
});
} catch (error) {
console.log(
Expand All @@ -246,13 +256,6 @@ CommerceHandler.prototype.logImpressionEvent = function (event, affiliation) {
);
return false;
}

this.sendCommerceEventToGA4(
mapGA4EcommerceEventName(event),
ga4CommerceEventParameters
);

return true;
};

CommerceHandler.prototype.logViewCart = function (event, affiliation) {
Expand Down
3 changes: 2 additions & 1 deletion packages/GA4Client/src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ var ConsentHandler = require('./consent');
var EVENT_NAME_MAX_LENGTH = 40;
var EVENT_ATTRIBUTE_KEY_MAX_LENGTH = 40;
var EVENT_ATTRIBUTE_VAL_MAX_LENGTH = 100;
var EVENT_ATTRIBUTE_MAX_NUMBER = 100;
// maximum event attributes reduced to 99 instead of 100 since now we include send_to as GA4 event parameter
var EVENT_ATTRIBUTE_MAX_NUMBER = 99;

var USER_ATTRIBUTE_KEY_MAX_LENGTH = 24;
var USER_ATTRIBUTE_VALUE_MAX_LENGTH = 36;
Expand Down

0 comments on commit a9d6273

Please sign in to comment.