@@ -1287,6 +1287,92 @@ describe('Google Analytics 4 Event', function () {
12871287 done ( ) ;
12881288 } ) ;
12891289
1290+ it ( 'should include EventAttributes on GA4 add_shipping_info event when CheckoutOption has GA4.CommerceEventType add_shipping_info' , function ( done ) {
1291+ mParticle . forwarder . process ( {
1292+ CurrencyCode : 'USD' ,
1293+ EventName : 'Test add_shipping_info Event' ,
1294+ EventDataType : MessageType . Commerce ,
1295+ EventCategory : CommerceEventType . ProductCheckoutOption ,
1296+ EventAttributes : {
1297+ page_url : 'https://example.com/checkout' ,
1298+ page_path : '/checkout' ,
1299+ mpID : '123' ,
1300+ SessionID : 'session-abc' ,
1301+ foo : 'bar' ,
1302+ } ,
1303+ CustomFlags : {
1304+ 'GA4.CommerceEventType' : 'add_shipping_info' ,
1305+ 'GA4.ShippingTier' : 'ground' ,
1306+ } ,
1307+ ProductAction : {
1308+ ProductActionType : ProductActionType . Click ,
1309+ ProductList : [ ] ,
1310+ } ,
1311+ } ) ;
1312+
1313+ result = [
1314+ 'event' ,
1315+ 'add_shipping_info' ,
1316+ {
1317+ shipping_tier : 'ground' ,
1318+ coupon : null ,
1319+ items : [ ] ,
1320+ page_url : 'https://example.com/checkout' ,
1321+ page_path : '/checkout' ,
1322+ mpID : '123' ,
1323+ SessionID : 'session-abc' ,
1324+ foo : 'bar' ,
1325+ send_to : 'testMeasurementId' ,
1326+ } ,
1327+ ] ;
1328+ window . dataLayer [ 0 ] . should . eql ( result ) ;
1329+
1330+ done ( ) ;
1331+ } ) ;
1332+
1333+ it ( 'should include EventAttributes on GA4 add_payment_info event when CheckoutOption has GA4.CommerceEventType add_payment_info' , function ( done ) {
1334+ mParticle . forwarder . process ( {
1335+ CurrencyCode : 'USD' ,
1336+ EventName : 'Test add_payment_info Event' ,
1337+ EventDataType : MessageType . Commerce ,
1338+ EventCategory : CommerceEventType . ProductCheckoutOption ,
1339+ EventAttributes : {
1340+ page_url : 'https://example.com/checkout' ,
1341+ page_path : '/checkout' ,
1342+ mpID : '123' ,
1343+ SessionID : 'session-abc' ,
1344+ foo : 'bar' ,
1345+ } ,
1346+ CustomFlags : {
1347+ 'GA4.CommerceEventType' : 'add_payment_info' ,
1348+ 'GA4.PaymentType' : 'credit-card' ,
1349+ } ,
1350+ ProductAction : {
1351+ ProductActionType : ProductActionType . Click ,
1352+ ProductList : [ ] ,
1353+ } ,
1354+ } ) ;
1355+
1356+ result = [
1357+ 'event' ,
1358+ 'add_payment_info' ,
1359+ {
1360+ payment_type : 'credit-card' ,
1361+ coupon : null ,
1362+ items : [ ] ,
1363+ page_url : 'https://example.com/checkout' ,
1364+ page_path : '/checkout' ,
1365+ mpID : '123' ,
1366+ SessionID : 'session-abc' ,
1367+ foo : 'bar' ,
1368+ send_to : 'testMeasurementId' ,
1369+ } ,
1370+ ] ;
1371+ window . dataLayer [ 0 ] . should . eql ( result ) ;
1372+
1373+ done ( ) ;
1374+ } ) ;
1375+
12901376 it ( 'should log a view_cart event using ProductActionType.Unknown and a custom flag' , function ( done ) {
12911377 mParticle . forwarder . process ( {
12921378 CurrencyCode : 'USD' ,
0 commit comments