Tamio

Tracking API

Tamio tracks 14 built-in commerce and engagement events automatically, including product views, cart actions, checkout steps, purchases, search, login, sign-up, and page duration — see the full table below.

Enable tracking by pasting the Google or Meta tracking ID/snippet in the site admin under Site Settings > Tracking.

Developers can also use xScripts.tracking from merchant header or footer scripts to observe Tamio events, block or replace them, forward them to custom endpoints, or send custom events through the same consent-aware dispatcher.

For examples of how to use the tracking for custom events, see the "Examples" tab above.

Events

EventWhen It FiresGA4 EventMeta Event
View productProduct page loadsview_itemViewContent
View category/listCategory, listing, or search listing page loadsview_item_listViewItemList custom
Add to cartProduct is added to cartadd_to_cartAddToCart
Remove from cartProduct is removed from cartremove_from_cartRemoveFromCart custom
View cartCart or checkout modal opensview_cartViewCart custom
Begin checkoutCustomer continues from cart into checkoutbegin_checkoutInitiateCheckout
Add shipping infoShipping step is completedadd_shipping_infoAddShippingInfo custom
Add payment infoPayment step loadsadd_payment_infoAddPaymentInfo
PurchaseThank-you page loads after a paid orderpurchasePurchase
SearchSearch results are shown or submittedsearchSearch
LoginPortal login succeedsloginLogin custom
Sign upPortal registration succeedssign_upCompleteRegistration
Page duration milestoneVisible page time reaches a milestonepage_durationPageDuration custom
Page duration exitVisitor leaves or an attention-taking overlay opens after minimum visible timepage_duration_endPageDurationEnd custom

view_item fires only on product pages and carries the product details — it is a reliable marker for "this is a product page" even when the URL has no fixed pattern.

Page duration

Default milestones are 5, 10, 30, 60, 120, and 300 seconds. Time is measured as active time — it pauses when the tab is in the background.

Every page_duration event uses the same name but carries parameters that tell the milestones apart:

ParameterExampleMeaning
milestone_seconds30The milestone that fired (5, 10, 30, ...)
event_label"30_seconds"The same milestone as a label
duration_seconds32Actual visible (active) time when it fired
page_path/sv/product/blue-shirtPage the event came from
finalfalsetrue only on the page_duration_end exit event

In GA4 reports you separate the milestones by filtering on milestone_seconds (register it once as a custom dimension) — you do not need a different event name per milestone. For a dedicated Google Ads conversion you do need a distinct event name, since Ads matches on the name; see the product-engagement example in the tab above.

Observe events — onEvent(handler)

Registers a handler that runs for every native and custom event, after Tamio has resolved consent and active destinations. Returns an unsubscribe function; offEvent(handler) also removes it.

The handler receives an event object:

Field / methodDescription
typeGeneric event name, such as add_to_cart or purchase
dataNormalized event payload
targetsDestinations that will receive the event, such as ["google"] or ["google", "facebook"]
event.preventDefault()Stop the event from being sent to any destination
event.preventDefaultFor(platform)Stop the event for one destination only — 'google' or 'facebook'

Returning false from the handler is the same as calling event.preventDefault().

Send custom events — track(name, data, options)

Adds a merchant-defined event to the same pipeline as native events, so it still passes consent checks and destination routing.

  • name — generic event name (string).
  • data — plain JSON payload.
  • options.platforms — optional array restricting destinations, e.g. ['google']. Without it, the event goes to every consented destination.

trackCustom is an alias of track.

Block or replace events

Because an onEvent handler can both cancel an event and emit a new one with track, you can replace a built-in event with your own: block the original (or keep it) and send a cleaner, purpose-named version. This is the basis of the product-engagement conversion recipe.

CallEffect
event.preventDefault() / return falseStop the event for all destinations
event.preventDefaultFor('google')Stop the event for Google only (GA4 and Google Ads)
event.preventDefaultFor('facebook')Stop the event for Meta only

google covers both GA4 and Google Ads, so blocking it removes the event from GA4 reports as well.

Notes

  • onEvent is for observing, blocking, or replacing events.
  • track is for adding merchant custom events.
  • Use generic event names and plain JSON payloads.
  • Scripts can go in the header or footer — handlers only run after Tamio initializes, so they never miss events.
  • Avoid overwriting window.xScripts or xScripts.tracking.