Skip to content

Customer events

content_for_header loads a small script that publishes customer events: what shoppers do, for the store’s analytics and for pixels (Google, Meta, TikTok, Snapchat, custom pixels) the merchant connects in admin. Themes can listen to them and publish their own.

Event When data
page_viewed Every page —
product_viewed Product pages product_id, variant_id, value, currency
collection_viewed Collection pages collection_id
search_submitted Search results query
cart_viewed The cart page —
product_added_to_cart After a successful /cart/add.js product_id, variant_id, quantity, value, currency
checkout_started Checkout opens order totals
checkout_completed The order is placed order_id, value, currency

value is in minor units. You don’t publish these yourself: they’re sent for you.

Sooquna.analytics.subscribe("product_added_to_cart", (event) => {
// event: { name, id, timestamp, data, context: { url, title, referrer } }
openCartDrawer();
});
Sooquna.analytics.subscribe("all_events", (event) => console.debug(event.name, event.data));
Sooquna.analytics.publish("size_guide_opened", { product_id: "…" });

Custom events reach the store’s analytics and custom pixels. Pass { local: true } as a third argument to notify subscribers on the page only.

In regions that require it, nothing but strictly necessary cookies is used until the shopper agrees. A banner asks for you; themes can read and set the choice:

const privacy = Sooquna.customerPrivacy;
privacy.analyticsProcessingAllowed(); // true or false
privacy.marketingAllowed();
privacy.setTrackingConsent({ analytics: true, marketing: false }, () => {});
document.addEventListener("sooquna:consent", (e) => console.log(e.detail));

Pixels load only after consent allows them. A custom pixel runs in a sandboxed frame with no access to the page, and receives events by message.

window.Sooquna also has shop, locale, currency, page_type, design_mode and routes (cart_add_url, cart_url, predictive_search_url…), so scripts don’t need them printed into the page. window.Shopify points to the same object, for ported scripts.

Was this page helpful?