diff --git a/packages/GA4Client/src/common.js b/packages/GA4Client/src/common.js index b993332..c99ff76 100644 --- a/packages/GA4Client/src/common.js +++ b/packages/GA4Client/src/common.js @@ -58,11 +58,7 @@ Common.prototype.truncateAttributes = function ( if (!isEmpty(attributes)) { Object.keys(attributes).forEach(function (attribute) { - var standardizedKey = attribute.replace( - FORBIDDEN_CHARACTERS_REGEX, - '_' - ); - var key = truncateString(standardizedKey, keyLimit); + var key = truncateString(attribute, keyLimit); var val = truncateString(attributes[attribute], valueLimit); truncatedAttributes[key] = val; }); diff --git a/packages/GA4Client/test/src/tests.js b/packages/GA4Client/test/src/tests.js index d4f0350..758d82d 100644 --- a/packages/GA4Client/test/src/tests.js +++ b/packages/GA4Client/test/src/tests.js @@ -1571,6 +1571,29 @@ describe('Google Analytics 4 Event', function () { done(); }); + it('should not standardize event names and event attributes if data cleansing is not enabled', function (done) { + mParticle.forwarder.process({ + EventDataType: MessageType.PageEvent, + EventCategory: EventType.Navigation, + EventName: '2?Test Event ?Standardization', + EventAttributes: { + foo: 'bar', + '1?test4ever!!!': 'tester', + }, + }); + + var expectedEventName = '2?Test Event ?Standardization'; + + var expectedEventAttributes = { + foo: 'bar', + '1?test4ever!!!': 'tester', + }; + + window.dataLayer[0][1].should.eql(expectedEventName); + window.dataLayer[0][2].should.eql(expectedEventAttributes); + done(); + }); + // This test exist for backwards compatibility of custom flags carried // over from legacy Google Analytics - Google.Title and Google.Location it('should log page view with legacy GA custom flags', function (done) {