Advertisement
Vojkovic

Purchase

Dec 24th, 2023 (edited)
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. window.dataLayer = window.dataLayer || [];
  2. window.dataLayer.push({ ecommerce: null });  // Clear previous ecommerce data
  3. window.dataLayer.push({
  4.   event: "purchase",
  5.   ecommerce: {
  6.     // EVENT LEVEL DATA OBJECT
  7.     event_details: {
  8.       event_id: "136851e7-3dca-46ac-b459-5ff8017d5820",  // Unique Event ID
  9.       content_group: "Product Detail",                   // Page Type
  10.       currency: "EUR",                                   // Currency Code
  11.       value: 14.50                                       // The monetary value of the event. Set the value to the sum of (price * quantity) for all items in items. Don't include shipping or tax.
  12.       transaction_id: "abc12312"                         //The unique identifier of a transaction.
  13.       shipping: "3.33"                                   //Shipping cost associated with a transaction.
  14.       tax: "1.11"                                        //Tax cost associated with a transaction.
  15.       coupon: 20%                                        // The coupon name/code associated with the item. Event-level and item-level coupon parameters are independent.
  16.     },
  17.     // USER DATA OBJECT
  18.     user_details: {
  19.       user_email: '[email protected]'                     // User Email
  20.     }
  21.   },
  22.   // GA4 ITEMS ARRAY
  23.   items: [{
  24.     item_id: "123abc",                                   // item SKU
  25.     item_name: "Skin Tracking Kit",                      // Product Name
  26.     affiliation: "Online Store",                         // Site Segment
  27.     currency: "EUR",                                     // Product Currency Code
  28.     coupon: "SUMMER_SOLUTION",                           // Product Level Coupon/Promo
  29.     discount: 5.00,                                      // Product Level Discount for Sale items
  30.     index: 0,                                            // Product Position in List
  31.     item_brand: "Mesagona",                              // Product Brand
  32.     item_category: "",                                   // Shop by Category
  33.     item_category2: "",                                  // Product Category 2
  34.     item_category3: "",                                  // Product Category 3
  35.     item_category4: "",                                  // Product Category 4
  36.     item_category5: "",                                  // Product Category 5
  37.     item_variant: "",                                    // Product Variant
  38.     location_id: "Product Detail",                       // Current Page Type | Event Location
  39.     price: 14.50,                                        // Product Price | Actual Selling Price
  40.     quantity: 1                                          // Quantity Added to Cart
  41.   }]
  42. });
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement