Advertisement
NFJMEDIA

Purchase

Dec 28th, 2022 (edited)
158
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.   user_data:{
  5.     em: 'email',                                   // user email                      
  6.     fn:'first_name',                               // user firstname
  7.     ln:'last_name',                                // user lastaname
  8.     ph:'phone_number',                             // user phone number
  9.     user_id: '1234abc1',                           // unique user_id
  10.     street: 'street',                              // user street
  11.     house_number: 'house number',                  // user house number
  12.     ct: 'city',                                    // user city
  13.     st: 'state',                                   // user state
  14.     zp: 'zipcode',                                 // user zipcode
  15.     country: 'country'                             // user country
  16.  },
  17.   ecommerce: {
  18.     currency: 'EUR',
  19.     value: 29.98,                       // order total (price of all products + shipping). If you want, it can be only price of all products
  20.     tax: 3.00,                          // tax
  21.     shipping: 5.00,                 // shipping costs
  22.     affiliation: 'My online shop',      // affiliation (e.g. affiliate id, name of the store, etc.)
  23.     transaction_id: 'abc123',           // transaction id
  24.     coupon: 'ENDOFSUMMER',          // if coupon was applied to the order, include it here         
  25.     items: [{                           // an array with all products
  26.       item_name: 'Product 1',           // insert an actual product name
  27.       item_id: 'product1',              // insert an actual product ID
  28.       price: 11.99,                 // insert an actual product price. Number or a string. Don't include currency code
  29.       item_brand: 'brand A',            // insert an actual product brand
  30.       item_category: 'Apparel',         // insert an actual product top-level category
  31.       item_category2: 'T-shirt',        // if it is possible to drill down the categories (e.g. Apparel, then T-shirt, then Men), use item_category2, item_category3, etc. Can use from item_category up to item_category5
  32.       item_variant: 'Blue',             // insert an actual product variant
  33.       quantity: '1',                    // product quantity
  34.       item_coupon: 'SUMMER20'           // if a coupon was applied not to the entire order but to one product, use item_coupon
  35.     },{
  36.       item_name: 'Product 2',
  37.       item_id: 'product2',
  38.       price: 12.99,
  39.       item_brand: 'Brand B',
  40.       item_category: 'Category B',
  41.       item_variant: 'Yellow',
  42.       quantity: '1'
  43.     }]
  44.   }
  45. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement