@grainql/analytics-web/react. Every block uses Analytics Web. The template methods send the
events add_to_cart, remove_from_cart, checkout, purchase, and search. The dashboard
reads them by these names. Read E-commerce tracking for the funnel and
the rules.
Product view
There is no template method for a product view. Usetrack with useTrack.
Add to cart
trackAddToCart takes itemId, itemName, price, quantity, currency, category, and
variant. useGrainAnalytics returns the client that holds the template methods.
Remove from cart
trackRemoveFromCart takes the same properties as trackAddToCart.
Checkout
CalltrackCheckout when the checkout starts, with the cart as items. Each item holds id,
name, price, and quantity. If the payment fails, call it again with success: false and
the errorMessage.
createOrder and processPayment are functions of your shop.
Purchase
CalltrackPurchase on the order confirmation page, with { flush: true }. The flush sends the
event before the visitor leaves the page. trackPurchase takes orderId, total, currency,
items, paymentMethod, shippingMethod, tax, shipping, discount, and couponCode.
order.id, so a re-render with the same order sends one purchase
event.
Search
trackSearch takes query, results, filters, sortBy, category, and success. Call it
after the results arrive, so results holds the count.
@grainql/analytics-web win over this page when they disagree. Read
Template events.