BuddyStat

E-commerce Events

Track product views, cart actions, and purchases with cookieless e-commerce events and a GA4/Shopify dataLayer adapter.

E-commerce events give you a canonical, GA4-compatible vocabulary for product and checkout activity — view_item, add_to_cart, begin_checkout, purchase, and more — each carrying an items[] array. They are cookieless and first-party: product IDs, order IDs, and revenue only, no customer PII, no consent banner.

Enabling e-commerce tracking

Add data-track-ecommerce to your script tag. To use a custom dataLayer name (instead of the default dataLayer), set data-ecommerce-data-layer:

<script
  src="https://app.buddystat.com/api/script.js"
  data-site-id="YOUR_SITE_ID"
  data-track-ecommerce
  defer
></script>

Using the helpers

Once enabled, window.buddystat.ecommerce exposes the full event surface:

// Product view
window.buddystat.ecommerce.viewItem({
  id: "sku-123",
  name: "Canvas Tote",
  price: 29.99,
  quantity: 1,
  category: "Bags",
  variant: "Black",
});

// Add / remove from cart
window.buddystat.ecommerce.addToCart({ id: "sku-123", price: 29.99, quantity: 2 });
window.buddystat.ecommerce.removeFromCart({ id: "sku-123", price: 29.99, quantity: 1 });

// Checkout
window.buddystat.ecommerce.beginCheckout(items, "SAVE10");
window.buddystat.ecommerce.addPaymentInfo(items);

// Purchase (feeds revenue: MRR/ARR/ARPU/AOV + server-side pixels)
window.buddystat.ecommerce.purchase({
  orderId: "ORD-12345",
  revenue: 59.98,
  currency: "EUR",
  coupon: "SAVE10",
  items: [
    { id: "sku-123", name: "Canvas Tote", price: 29.99, quantity: 2 },
  ],
});

// Refund
window.buddystat.ecommerce.refund({ orderId: "ORD-12345", revenue: 29.99, currency: "EUR" });

Event reference

EventHelpersPayload highlights
view_itemecommerce.viewItem(item)items[]
view_item_listecommerce.viewItemList(items, listName?)items[], list_name
select_itemecommerce.selectItem(item)items[]
add_to_cartecommerce.addToCart(item)items[]
remove_from_cartecommerce.removeFromCart(item)items[]
begin_checkoutecommerce.beginCheckout(items?, coupon?)items[], coupon
add_payment_infoecommerce.addPaymentInfo(items?, coupon?)items[], coupon
purchaseecommerce.purchase(order)revenue, value, currency, orderId, coupon, items[]
refundecommerce.refund(order)revenue, value, currency, orderId, items[]

Each items[] entry supports id, name, price, quantity, category, variant, and coupon.

GA4 / Shopify dataLayer adapter

With data-track-ecommerce set, BuddyStat observes your existing window.dataLayer pushes and maps them automatically — no code changes:

  • GA4 style: dataLayer.push({ event: "add_to_cart", ecommerce: { currency, value, items: [...] } })
  • Shopify / UA style: dataLayer.push({ ecommerce: { add: { products: [...] }, purchase: { actionField, products } } })

The adapter is read-only: it never blocks or modifies your dataLayer, so your existing GA4/Shopify pixel keeps working unchanged.

Revenue & pixels

purchase events carry revenue, currency, and orderId, so they automatically:

  • Feed the Revenue dashboard (MRR, ARR, ARPU, AOV, channel breakdown).
  • Reach server-side pixels (Meta, Google Ads, TikTok, Pinterest, LinkedIn) via CAPI — with orderId available for deduplication.

Privacy

  • No cookies, no fingerprinting, no consent banner (GDPR/CCPA compliant by design).
  • Only product IDs, order IDs, and revenue are collected — never customer contact data.
  • All data is stored on EU infrastructure.

On this page