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
- An exact origin:
- Content-Security-Policy. If your site sends a CSP header, add:
Install
Put this snippet in the<head> of every page, with your pixel id:
- Catalog table.
itemIdRelationnames the catalog table your item ids come from, such asproducts. Every event with an item id carries it asitem_id_relation. - Session and customer ids. If your site calls Recommendations with a
session_id, pass that same id toinitassessionId, and your customer id asuserId. 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.
initsends apage_viewwhen the pixel loads. If you send your own page views withsequen("page", …), put that call in the same snippet, or setautoPage: 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
keepaliverequest.
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.
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.With markup (recommended)
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.
rank and module_name as its impression. click_type is required:
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.
init, and the pixel uses them instead of its own:
sessionIdis sent assid, and the pixel keeps no session of its own. If it is empty, the pixel falls back to its own session.userIdis sent asuid. It is never stored, so pass it on every page, and""when the shopper is logged out.
Consent
If your consent manager must approve tracking first, start the pixel withconsent: "pending". Nothing is stored or sent until consent is granted:
"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 withtrack:
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 setscid, 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
Refererheader. Don’t setreferrerpolicy="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.
