Help

Add the website snippet and send events

The website snippet is one line of script for your site. It records page views by itself, and product views and carts when your site tells it to, and it recognises visitors who arrive from one of your emails. That powers browse abandonment and cart flows and segments such as “viewed a product 3 times this month”. It sets no cookies.

A web page can be made to say anything, so a browser may only report browsing. Checkouts, orders and events of your own must come from your server, through the API.

Last updated

Add it to your site

  1. Open Settings > Site tracking. Only owners and admins can set it up.
  2. Type Your site’s address, for example https://yourshop.com. The snippet only works from the sites you list, so nobody else can use your key. Add any other host your product images or links are on.
  3. Press Get the snippet.
  4. Paste the line it gives you on every page of your site, before </body>.

Tell it more

The snippet records page views by itself. Call it for anything else:

// What they looked at, and what they put in their cart
sendsational("track", "product_viewed", { product_id: "p1", title: "Lunch box", price: 12.5 });
sendsational("track", "added_to_cart", { product_id: "p1", quantity: 1 });

// A single-page app: tell us when the page changes
sendsational("page");

// Someone signed in, or gave you their address
sendsational("identify", "maya@example.com");

Only the details a browsing event is known to have are kept: product id, title, address, image, price, currency and categories, and for a cart the cart’s address and quantity. An address in an event must be on one of the sites you listed.

Who is browsing

  • Someone who arrives from one of your emails is known for certain: every link in your emails carries a signed id. Their browsing counts in segments and can start flows.
  • identify, and a form with an email field, link the browser to a contact you already have, but what that browser does is kept as unverified: anyone could type someone else’s address. Segments and revenue do not count it.
  • A visitor nobody knows yet is remembered for 30 days. If they become a contact in that time, their earlier browsing is filed under them.

The snippet never creates a contact.

Which events come from where

EventFrom the snippetFrom your server (API)
Page viewsYes, by itselfYes
product_viewed, added_to_cartYesYes
checkout_started, order_placed, order_fulfilledNoYes
Your own events, such as quiz_completedNoYes

Questions

Does it slow my site down?

It loads after your page, asynchronously, and sends small batches.

It sets no cookies; it keeps a random visitor id in the browser’s local storage. Whether you need consent for that depends on where you and your visitors are; check the rules that apply to you.

Can someone fake events with my key?

The key is public, so the snippet is deliberately limited: it only works from your sites, only accepts browsing, never creates contacts, and its events about unverified visitors do not count.

All help topics · API reference