From b2991dbca036a34ab0ac8cf360b134d5f957a956 Mon Sep 17 00:00:00 2001 From: mparticle-automation Date: Mon, 5 May 2025 18:31:34 +0000 Subject: [PATCH 1/4] chore(build): Generate latest bundle [skip ci] --- .../GoogleAnalytics4EventForwarderClientSide-Kit.common.js | 3 +++ .../dist/GoogleAnalytics4EventForwarderClientSide-Kit.iife.js | 3 +++ 2 files changed, 6 insertions(+) diff --git a/packages/GA4Client/dist/GoogleAnalytics4EventForwarderClientSide-Kit.common.js b/packages/GA4Client/dist/GoogleAnalytics4EventForwarderClientSide-Kit.common.js index f77eca6..4cb9e05 100644 --- a/packages/GA4Client/dist/GoogleAnalytics4EventForwarderClientSide-Kit.common.js +++ b/packages/GA4Client/dist/GoogleAnalytics4EventForwarderClientSide-Kit.common.js @@ -930,6 +930,9 @@ function parseProduct(product, affiliation) { case 'Variant': productWithAllAttributes.item_variant = product.Variant; break; + case 'Position': + productWithAllAttributes.index = product.Position; + break; case 'Attributes': break; default: diff --git a/packages/GA4Client/dist/GoogleAnalytics4EventForwarderClientSide-Kit.iife.js b/packages/GA4Client/dist/GoogleAnalytics4EventForwarderClientSide-Kit.iife.js index 69eb76c..76c1ae8 100644 --- a/packages/GA4Client/dist/GoogleAnalytics4EventForwarderClientSide-Kit.iife.js +++ b/packages/GA4Client/dist/GoogleAnalytics4EventForwarderClientSide-Kit.iife.js @@ -929,6 +929,9 @@ var GoogleAnalytics4Kit = (function (exports) { case 'Variant': productWithAllAttributes.item_variant = product.Variant; break; + case 'Position': + productWithAllAttributes.index = product.Position; + break; case 'Attributes': break; default: From 6cb433c78932c06da4dedcb66b5ef6e8455bf1a4 Mon Sep 17 00:00:00 2001 From: mparticle-automation Date: Mon, 5 May 2025 18:31:35 +0000 Subject: [PATCH 2/4] chore(release): 1.5.0 [skip ci] # [1.5.0](https://github.com/mparticle-integrations/mparticle-javascript-integration-google-analytics-4/compare/v1.4.5...v1.5.0) (2025-05-05) ### Features * Map product position to GA4 item index ([#62](https://github.com/mparticle-integrations/mparticle-javascript-integration-google-analytics-4/issues/62)) ([308076c](https://github.com/mparticle-integrations/mparticle-javascript-integration-google-analytics-4/commit/308076cc22b6a7f9e78bfb0c40486654e09a2a98)) --- packages/GA4Client/CHANGELOG.md | 7 +++++++ packages/GA4Client/package-lock.json | 6 +++--- packages/GA4Client/package.json | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/GA4Client/CHANGELOG.md b/packages/GA4Client/CHANGELOG.md index 6bdea12..337e0d7 100644 --- a/packages/GA4Client/CHANGELOG.md +++ b/packages/GA4Client/CHANGELOG.md @@ -1,3 +1,10 @@ +# [1.5.0](https://github.com/mparticle-integrations/mparticle-javascript-integration-google-analytics-4/compare/v1.4.5...v1.5.0) (2025-05-05) + + +### Features + +* Map product position to GA4 item index ([#62](https://github.com/mparticle-integrations/mparticle-javascript-integration-google-analytics-4/issues/62)) ([308076c](https://github.com/mparticle-integrations/mparticle-javascript-integration-google-analytics-4/commit/308076cc22b6a7f9e78bfb0c40486654e09a2a98)) + ## [1.4.5](https://github.com/mparticle-integrations/mparticle-javascript-integration-google-analytics-4/compare/v1.4.4...v1.4.5) (2024-10-09) diff --git a/packages/GA4Client/package-lock.json b/packages/GA4Client/package-lock.json index 481915f..c637159 100644 --- a/packages/GA4Client/package-lock.json +++ b/packages/GA4Client/package-lock.json @@ -1,12 +1,12 @@ { "name": "@mparticle/web-google-analytics-4-client-kit", - "version": "1.4.5", + "version": "1.5.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@mparticle/web-google-analytics-4-client-kit", - "version": "1.4.5", + "version": "1.5.0", "license": "Apache-2.0", "dependencies": { "@mparticle/web-sdk": "^2.12.2", @@ -23215,4 +23215,4 @@ "dev": true } } -} \ No newline at end of file +} diff --git a/packages/GA4Client/package.json b/packages/GA4Client/package.json index c99ca19..cbe7f5d 100644 --- a/packages/GA4Client/package.json +++ b/packages/GA4Client/package.json @@ -1,6 +1,6 @@ { "name": "@mparticle/web-google-analytics-4-client-kit", - "version": "1.4.5", + "version": "1.5.0", "author": "mParticle Developers (https://www.mparticle.com)", "description": "mParticle integration sdk for Google Analytics", "main": "dist/GoogleAnalytics4EventForwarderClientSide-Kit.common.js", From 969a54fa78b2f59fa0362e1a8b50d58c4e9c7852 Mon Sep 17 00:00:00 2001 From: Khushi Patel Date: Tue, 3 Mar 2026 12:32:41 -0500 Subject: [PATCH 3/4] add attribute merging to logCheckoutOptionEvent --- packages/GA4Client/src/commerce-handler.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/GA4Client/src/commerce-handler.js b/packages/GA4Client/src/commerce-handler.js index e679d5b..7d4bd75 100644 --- a/packages/GA4Client/src/commerce-handler.js +++ b/packages/GA4Client/src/commerce-handler.js @@ -202,6 +202,11 @@ CommerceHandler.prototype.logCheckoutOptionEvent = function ( return false; } + ga4CommerceEventParameters = this.common.mergeObjects( + ga4CommerceEventParameters, + this.common.limitEventAttributes(event.EventAttributes) + ); + return this.sendCommerceEventToGA4( mapGA4EcommerceEventName(event), ga4CommerceEventParameters From a98c8f30b25bdafd16869a79638463e84bf3dff4 Mon Sep 17 00:00:00 2001 From: Khushi Patel Date: Tue, 3 Mar 2026 12:41:02 -0500 Subject: [PATCH 4/4] added test coverage --- packages/GA4Client/test/src/tests.js | 86 ++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/packages/GA4Client/test/src/tests.js b/packages/GA4Client/test/src/tests.js index a9f688c..3823c4d 100644 --- a/packages/GA4Client/test/src/tests.js +++ b/packages/GA4Client/test/src/tests.js @@ -1287,6 +1287,92 @@ describe('Google Analytics 4 Event', function () { done(); }); + it('should include EventAttributes on GA4 add_shipping_info event when CheckoutOption has GA4.CommerceEventType add_shipping_info', function (done) { + mParticle.forwarder.process({ + CurrencyCode: 'USD', + EventName: 'Test add_shipping_info Event', + EventDataType: MessageType.Commerce, + EventCategory: CommerceEventType.ProductCheckoutOption, + EventAttributes: { + page_url: 'https://example.com/checkout', + page_path: '/checkout', + mpID: '123', + SessionID: 'session-abc', + foo: 'bar', + }, + CustomFlags: { + 'GA4.CommerceEventType': 'add_shipping_info', + 'GA4.ShippingTier': 'ground', + }, + ProductAction: { + ProductActionType: ProductActionType.Click, + ProductList: [], + }, + }); + + result = [ + 'event', + 'add_shipping_info', + { + shipping_tier: 'ground', + coupon: null, + items: [], + page_url: 'https://example.com/checkout', + page_path: '/checkout', + mpID: '123', + SessionID: 'session-abc', + foo: 'bar', + send_to: 'testMeasurementId', + }, + ]; + window.dataLayer[0].should.eql(result); + + done(); + }); + + it('should include EventAttributes on GA4 add_payment_info event when CheckoutOption has GA4.CommerceEventType add_payment_info', function (done) { + mParticle.forwarder.process({ + CurrencyCode: 'USD', + EventName: 'Test add_payment_info Event', + EventDataType: MessageType.Commerce, + EventCategory: CommerceEventType.ProductCheckoutOption, + EventAttributes: { + page_url: 'https://example.com/checkout', + page_path: '/checkout', + mpID: '123', + SessionID: 'session-abc', + foo: 'bar', + }, + CustomFlags: { + 'GA4.CommerceEventType': 'add_payment_info', + 'GA4.PaymentType': 'credit-card', + }, + ProductAction: { + ProductActionType: ProductActionType.Click, + ProductList: [], + }, + }); + + result = [ + 'event', + 'add_payment_info', + { + payment_type: 'credit-card', + coupon: null, + items: [], + page_url: 'https://example.com/checkout', + page_path: '/checkout', + mpID: '123', + SessionID: 'session-abc', + foo: 'bar', + send_to: 'testMeasurementId', + }, + ]; + window.dataLayer[0].should.eql(result); + + done(); + }); + it('should log a view_cart event using ProductActionType.Unknown and a custom flag', function (done) { mParticle.forwarder.process({ CurrencyCode: 'USD',