Advertisement
chiragsolanki

purchase datalayer script

Sep 14th, 2023 (edited)
862
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: 'GA4_purchase',            // name of the event. In this case, it always must be purchase
  4.   ecommerce: {
  5.     currency: 'USD',
  6.     value: 49.00,                       // order total (price of all products + shipping). If you want, it can be only price of all products
  7.     tax: 3.00,                          // tax
  8.     shipping: 5.00,                 // shipping costs
  9.     transaction_id: 'abc123',           // transaction id
  10.     coupon: 'ENDOFSUMMER',          // if coupon was applied to the order, include it here          
  11.     items: [{                           // an array with all products
  12.       item_name: 'Ground Criollo Beef',           // insert an actual product name
  13.       item_id: 'product1',              // insert an actual product ID
  14.       price: 25.99,                 // insert an actual product price. Number or a string. Don't include currency code
  15.       item_brand: 'brand A',            // insert an actual product brand
  16.       item_category: 'Criollo Beef',         // insert an actual product top-level category
  17.       quantity: '1',                    // product quantity
  18.       item_coupon: 'SUMMER20'           // if a coupon was applied not to the entire order but to one product, use item_coupon
  19.     },{
  20.       item_name: 'Tenderloin Filet',
  21.       item_id: 'product2',
  22.       price: 15.99,
  23.       item_brand: 'Brand B',
  24.       item_category: 'Premium Steaks',
  25.       quantity: '1'
  26.     }]
  27.   }
  28. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement