vtex-apps/google-tag-manager

GA4 - OrderPlaced Event / Purchase Event - Missing affiliation

claudiubee opened this issue · 0 comments

Describe the bug
transactionAffiliation / affiliation should be set per item.
Current event payload for purchase (with Send Google Analytics 4 Events active):

dataLayer.push({
  event: "purchase",
  ecommerce: {
    transaction_id: "1333180500286",
    value: 5085.66,
    tax: 0,
    shipping: 5,
    coupon: null,
    items: [
      {
        item_id: "55",
        item_name: "G-Series G55-1850 Supercore Standard Rotation 85MM Comp Ind",
        item_brand: "Demo",
        item_variant: "76",
        price: 5080.66,
        quantity: 1,
        item_category: "Supercores",
        dimension1: "",
        dimension2: "880547-5001S",
        dimension3: "G-Series G55-1850 Supercore Standard Rotation 85MM Comp Ind",
        dimension4: "available"
      }
    ],
    currency: "USD"
  },
  gtm.uniqueEventId: 309
})

Expected payload:

dataLayer.push({
  event: "purchase",
  ecommerce: {
    ...
    items: [
      {
            affiliation: "Seller Demo",
      }
    ],
    currency: "USD"
  },
  gtm.uniqueEventId: 309
})

OrderPlaced event contains the affiliation but not at item level.
Current payload:

dataLayer.push({
  event: "orderPlaced",
  currency: "USD",
  eventName: "vtex:orderPlaced",
  ...
  ecommerceV2: {
    ecommerce: {
      purchase: {
        actionField: {
          affiliation: "Demo Seller",
          coupon: null,
          id: "1333180500286",
          revenue: 5085.66,
          shipping: 5,
          tax: 0
        },
        products: [
          {
            brand: "Demo",
            category: "Turbochargers/Supercores",
            id: "55",
            variant: "76",
            name: "G-Series G55-1850 Supercore Standard Rotation 85MM Comp Ind",
            price: 5080.66,
            quantity: 1,
            dimension1: "",
            dimension2: "880547-5001S",
            dimension3: "G-Series G55-1850 Supercore Standard Rotation 85MM Comp Ind"
          }
        ]
      }
    }
  },
  gtm.uniqueEventId: 364
})

Expected payload:

dataLayer.push({
  event: "orderPlaced",
  currency: "USD",
  eventName: "vtex:orderPlaced",
  ...
  ecommerceV2: {
    ecommerce: {
      purchase: {
        actionField: {
          affiliation: "Demo Seller",
          coupon: null,
          id: "1333180500286",
          revenue: 5085.66,
          shipping: 5,
          tax: 0
        },
        products: [
          {
            ...
            affiliation: "Demo Seller",
            ...
          }
        ]
      }
    }
  },
  gtm.uniqueEventId: 364
})