track call with a fixed event name and a TypeScript type for its
properties. trackLogin({ method: 'email' }) sends the same event as
track('login', { method: 'email' }). The type tells your editor which properties exist, and every
part of your code sends the event with the same name. Analytics Web has eight template methods.
Grain Tag has none. It sends every event with track.
Methods
Every method has the signature
(properties?, options?) and returns Promise<void>. options
is SendEventOptions, which holds one field, flush. With flush: true, the SDK sends the event
at once instead of the next batch. Read Track an event.
Record<string, unknown>, so you can add
your own keys next to the typed ones. The types in @grainql/analytics-web win over the tables on
this page.
trackLogin
trackSignup
trackCheckout
trackPurchase
checkout marks the start or the end of a checkout. purchase marks a completed transaction.
Send both, and the dashboard shows the checkout completion rate as a track. Read
Tracks.
trackAddToCart
trackRemoveFromCart
RemoveFromCartEventProperties has the same fields as AddToCartEventProperties.
trackPageView
Both SDKs track page views without code. CalltrackPageView only when automatic page views are
off, or when a route change is not visible to the SDK. Read
Automatic tracking.
trackSearch
track with your own name. Read
Name events. A full shop flow with these methods is in
E-commerce tracking.