Skip to main content
The Sequen pixel is a small script (about 6 KB compressed) that sends shopper events from your website straight to Sequen. Use it when you can’t send events from your backend, or when you don’t store event history yourself. Sequen uses these events to rank products for each shopper, including within the current session. The events that matter most are page views, searches, impressions (what was shown, and where), clicks, add to cart and purchases. The pixel needs no API key. It carries a public pixel id that identifies your site.

Before you start

You need three things in place: a pixel id, your origins registered with Sequen, and your Content-Security-Policy updated.
  • Pixel id. Six characters, like fK53sD. It is public, not a secret: it goes in your page code. Your Sequen account team creates it for you.
  • Origins. Tell Sequen every origin that will send events, including staging. Events from any other origin are refused. Origins match exactly, including the port.
    • An exact origin: https://www.example.com
    • Every subdomain: https://*.example.com
    • Local testing: http://localhost:<port>, with the port you test on
  • Content-Security-Policy. If your site sends a CSP header, add:
You don’t need a pixel id to start building. Use any id with debug: true and the pixel logs every event to the browser console without sending it. See Test, then go live.

Install

Put this snippet in the <head> of every page, with your pixel id:
  • Catalog table. itemIdRelation names the catalog table your item ids come from, such as products. Every event with an item id carries it as item_id_relation.
  • Session and customer ids. If your site calls Recommendations with a session_id, pass that same id to init as sessionId, and your customer id as userId. See Shopper ids.
  • Asynchronous. The script loads without blocking the page. Calls made before it loads are queued, and each keeps the time it was made.
  • Automatic page view. init sends a page_view when the pixel loads. If you send your own page views with sequen("page", …), put that call in the same snippet, or set autoPage: false.
  • Sent quickly. Events are sent within about 100 ms, so Sequen can personalize later pages in the same session. When the shopper leaves the page, anything left is sent with a keepalive request.
Using a tag manager such as Adobe Tags or Google Tag Manager? See Tag managers.

Page views

Send one page view on every page. page_type is required. Use a small fixed set, such as home, category, search, product_detail, cart, checkout and other, and share your list with Sequen.
A product page passes its item id:
A search results page passes the query and the results, in the order shown:
If you don’t pass page_type, the pixel uses the pageType init option, then <meta name="sqn:page_type" content="…"> on the page, then other. Single-page apps. Set spa: true in init and the pixel sends a page view on every history.pushState and back or forward navigation. Or send sequen("page", …) yourself on every route change, which lets you pass page_type and item ids.

Impressions and clicks

Impressions tell Sequen what each shopper saw, and where. Ranking models need what was shown as well as what was clicked, so these are the events Sequen most needs. You can send them with markup or with calls, but not both for the same events: each would be sent twice. Mark up each grid, carousel or ad slot, and each product tile in it. The pixel records impressions, module views and clicks on its own:
  • Impression. Sent when at least 50% of a tile is in view for 1 second, once per tile per page view.
  • Module view. Sent just before the module’s first impression.
  • Rank. For a tile, its position within the module, starting at 1. For a module, its position on the page.
  • Clicks link to impressions. A click on a tile that hasn’t logged an impression yet logs the impression first.
  • Late content. Tiles added after the page loads are picked up, so infinite scroll and lazy-loaded carousels work.

With calls

If you can’t change the page markup, send one impression per product shown. rank is required: the product’s position in that module, starting at 1.
Send a click when a shopper opens a product from a module, with the same rank and module_name as its impression. click_type is required:
Adding to a wishlist is a click with click_type: "product_favorite". When a Sequen response filled the module, pass its rec_id on both events.

Add to cart and purchase

item_ids is filled in from items, so you don’t need to send both.

Shopper ids

Every event carries up to three ids: sid and uid are the session_id and user_id of your Recommendations requests. Your page can’t read the pixel’s own session id, so if you send session_id to Recommendations, pass the same id to init as sessionId (see Your own ids below). Logins and logouts. Call identify when a shopper logs in and reset when they log out. reset clears uid and starts a new session.
Your own ids. If your site already has session and customer ids, pass them to init, and the pixel uses them instead of its own:
  • sessionId is sent as sid, and the pixel keeps no session of its own. If it is empty, the pixel falls back to its own session.
  • userId is sent as uid. It is never stored, so pass it on every page, and "" when the shopper is logged out.
Use the same customer and session ids everywhere you send them to Sequen, including your Recommendations requests, so events and requests can be matched. Send the raw customer id, not a hash, and never an email address or phone number.
If your consent manager must approve tracking first, start the pixel with consent: "pending". Nothing is stored or sent until consent is granted:
Any value other than "granted" counts as denied. A consent call made before the pixel loads wins over the init option. To store nothing in the browser at all, neither cookies nor localStorage, set cookies: false. cid is then new on every page load, so pair it with sessionId and userId.

Custom events

Send any other shopper action with track:
Tell your Sequen account team which custom event types you’ll send before you send them, so they can be enabled for your pixel. Events of a type that isn’t enabled are dropped. Debug mode doesn’t check this.

Event fields

The pixel sends the same events as the Events API, and follows its rules.

Event types

An event without its required field is dropped. Any other type is a custom event, and is dropped unless it is enabled for your pixel.

Standard fields

Use item_id when an event is about one product, and item_ids only for a list. Send item ids as strings.

Fields Sequen sets

The pixel sets cid, sid, uid (see Shopper ids), page_view_id and event_id, and records when each call was made, corrected for the browser’s clock. Sequen ignores any value you send for id, client_id, original_timestamp, server_timestamp, ingest_timestamp, ip_address and user_agent, and adds a few fields of its own whose names start with sqn_.

Custom fields

Any other field is a custom field and is kept as you send it: a string, number, boolean, array of strings or object. Send as many as you have. Sequen picks the ones that predict what shoppers do.
  • Names. Letters, digits, _, ., : and -, up to 64 characters. Fields with any other name are dropped.
  • Size. An event can be up to 16 KB. A larger one is dropped.

Image fallback

Use an image tag only where JavaScript can’t run. Each image sends one event, and the response is a 1×1 GIF.
  • The event time is when the request arrives.
  • Your origin is checked from the Referer header. Don’t set referrerpolicy="no-referrer" on the tag or the page, or the event is refused.

Test, then go live

Reference

Calls

Init options

What the pixel sends on its own

What every event carries

By default the pixel keeps the device id in the first-party cookie _sqn_c, its own session in _sqn_s, and the id from identify in _sqn_u.