Advertisement
Jawad_Khan

EEC- GA4 - purchase

Apr 6th, 2023 (edited)
627
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. window.dataLayer = window.dataLayer || [];
  2. window.dataLayer.push({
  3.   event: 'purchase',            // name of the event. In this case, it always must be purchase
  4.   userId: '123abc' // this should be replaced by actual user ID and cannot be PII e.g. email address or IP address
  5.   ecommerce: {
  6.     currency: 'PKR',
  7.     value: 29.98,                       // order total (price of all products + shipping)
  8.     tax: 3.00,                          // tax
  9.     shipping: 5.00,                 // shipping costs
  10.     transaction_id: 'abc123',           // transaction id
  11.     coupon: 'ENDOFSUMMER',          // if coupon was applied to the order, include it here         
  12.     items: [{                           // an array with all products
  13.       item_name: 'Product 1',           // insert an actual product name
  14.       item_id: 'product1',              // insert an actual product ID
  15.       price: 11.99,                 // insert an actual product price. Number or a string. Don't include currency code
  16.       item_brand: 'brand A',            // insert an actual product price
  17.       item_category: 'Apparel',         // insert an actual product top-level category
  18.      
  19.       quantity: '1',                    // product quantity
  20.       item_coupon: 'SUMMER20'           // if a coupon was applied not to the entire order but to one product, use item_coupon
  21.             },{
  22.       item_name: 'Product 2',
  23.       item_id: 'product2',
  24.       price: 12.99,
  25.       item_brand: 'Brand B',
  26.       item_category: 'Category B',
  27.       item_variant: 'Yellow',
  28.       quantity: '1'
  29.         }]
  30.   }
  31. });
  32.     }]
  33.   }
  34. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement