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.
Add it to your site
- Open Settings > Site tracking. Only owners and admins can set it up.
- 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. - Press Get the snippet.
- 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
| Event | From the snippet | From your server (API) |
|---|---|---|
| Page views | Yes, by itself | Yes |
product_viewed, added_to_cart | Yes | Yes |
checkout_started, order_placed, order_fulfilled | No | Yes |
Your own events, such as quiz_completed | No | Yes |