Advertisement
jaspacio

GA4 View Cart

Mar 9th, 2023
616
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
  2. dataLayer.push({
  3.   event: "view_cart",                           // name of an event. In this case, always stays as view_cart
  4.   ecommerce: {                                  // ecommerce object. This is the essential part of tracking. New EE data must always be pushed to this object
  5.     currency: "USD",                            // Currency of the items associated with the event
  6.     value: 7.77,                                // The monetary value of the event
  7.     items: [                                    // The items for the event - this is an array
  8.     {
  9.       item_id: "SKU_12345",                     // The ID of the item, in our case ISBN
  10.       item_name: "Stan and Friends Tee",        // The name of the item
  11.       affiliation: "Cambridge University Press and Assessment", // A product affiliation to designate a supplying company or brick and mortar store location. In our case, Cambridge University Press and Assessment
  12.       coupon: "SUMMER_FUN",                     // The coupon name/code associated with the item.
  13.       discount: 2.22,                           // The monetary discount value associated with the item.
  14.       index: 0,                                 // The index/position of the item in a list.
  15.       item_brand: "Google",                     // The brand of the item. In our case academic, education or cambridge english
  16.       item_category: "Apparel",                 // The category of the item. If used as part of a category hierarchy or taxonomy then this will be the first category.
  17.       item_category2: "Adult",                  // The second category hierarchy or additional taxonomy for the item.
  18.       item_category3: "Shirts",                 // The third category hierarchy or additional taxonomy for the item.
  19.       item_category4: "Crew",                   // The fourth category hierarchy or additional taxonomy for the item.
  20.       item_category5: "Short sleeve",           // The fifth category hierarchy or additional taxonomy for the item.
  21.       item_list_id: "related_products",         // The ID of the list in which the item was presented to the user. We may not be using this.
  22.       item_list_name: "Related Products",       // The name of the list in which the item was presented to the user. In this case Bag List
  23.       item_variant: "green",                    // The item variant or unique code or description for additional item details/options.
  24.       location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo", // The physical location associated with the item (e.g. the physical store location) NA
  25.       price: 9.99,                              // The monetary price of the item, in units of the specified currency parameter.
  26.       quantity: 1                               // Item quantity.
  27.     }
  28.     ]
  29.   }
  30. });
Tags: GA4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement