Overview
Tocadule is a first-party event pipeline with an activation layer on top. A tiny browser snippet sends events from your storefront to the Tocadule API. On the server we resolve the visitor's identity, enrich the event (geo, device, traffic source, ad click IDs), store it, and forward it server-side to your ad destinations (Meta CAPI, TikTok Events API, GA4). The same event stream powers audiences, segments, on-site popups, abandoned-cart automations, and analytics.
Because the forward to the ad platforms happens server-to-server, it does not depend on their browser pixels, and it carries match signals a browser pixel alone does not.
One install gives you both: a clean first-party data layer and the activation channels that read from it. You keep your existing pixels — Tocadule sits in their call path and dedupes against them rather than replacing them.
Install
Paste these three lines into your storefront <head> (or your theme's global template) as the first code,
above your pixels and tag manager (Meta, TikTok, Google Tag Manager).
Replace YOUR_WORKSPACE_ID with your workspace ID from Connections.
<link rel="preconnect" href="https://app.tocadule.com">
<script>window.tocadule=window.tocadule||{};window.tocadule._q=window.tocadule._q||[];['track','identify','cart','requestPush','setConsent'].forEach(function(m){window.tocadule[m]=window.tocadule[m]||function(){window.tocadule._q.push([m,arguments])}});</script>
<script async fetchpriority="high" data-workspace="YOUR_WORKSPACE_ID" src="https://app.tocadule.com/snippet.js"></script>Why three lines? The middle line is a tiny stub. It makes window.tocadule exist
immediately, so any tracking code that runs before the async snippet.js finishes
loading queues its calls into window.tocadule._q instead of silently no-oping. When
snippet.js loads, it builds the real API and replays the queue in order. This is what
lets you drop tocadule.track('purchase', …) directly into a template that renders
above your snippet tag.
If you have a verified custom domain, the install serves snippet.js from your own
subdomain (e.g. data.yourshop.com/snippet.js), and the snippet scopes its identity
cookie to your main domain so a visitor keeps one ID across www, checkout and
account. Only the snippet writes cookies; our server never sets one. The snippet
auto-derives its API base from wherever it was loaded — no extra config.
The API
The snippet exposes four functions on window.tocadule:
| Call | Purpose |
|---|---|
tocadule.track(name, props) | Send an event (page view, product view, purchase, or any custom name). |
tocadule.cart(data) | Send the visitor's whole current cart on every change. PII-free. |
tocadule.identify(email, traits) | Who the person is: at sign-up, in your common template for logged-in shoppers, on the order page for every buyer. Never added to an event. |
tocadule.setConsent({ analytics, ads }) | Your own consent manager's answer for the visitor (both lanes, every event). |
tocadule.requestPush(cb) | Prompt for web-push permission and subscribe the visitor. |
A lot happens automatically. On every track() call the snippet attaches UTM parameters,
device / browser / OS, traffic source (including AI-assistant referrers), ad click IDs
(gclid, gbraid, wbraid, fbclid, ttclid, …), page URL / path / title, locale, and screen metrics — so
your event payloads stay small and you don't repeat yourself. The snippet sends a page view
on every page; in the data centre you name your page types by their addresses (product,
category, cart, checkout, search, or your own), and Tocadule labels each page view on the
server. checkout_started, view_cart, view_item_list and search can come from those
page types (the page door) — checkout_started is then also sent to your ad destinations, once
per visit. Everything else is a track() call from your store: most importantly purchase
(with order_id + revenue), plus product_view, add_to_cart, sign_up and identify.
A cancelled or refunded order never happens in a shopper's browser: it comes from your
platform (Shopify), a Toca upload, or your server through the server API
(POST /v1/events, with an API key; for now it takes cancellations only).
Identity: events say what happened, the contact says who
Event rows never hold personal data: email, phone, names and other personal fields are
stripped before any event is stored. Customer details travel only on identity
events (identify — also right before a purchase — and our popup forms; an email on any other event is
only that event's ad match), which find or create the contact, the one place they are kept. Ad
platforms receive them hashed from the contact, only when the visitor allowed ads.
Once a browser is linked to a contact (only when the analytics consent lane allows it),
all of its events, including the earlier ones, resolve to that contact. So identify
shoppers early: ONE line in your site's common template calls identify when the shopper
is logged in (standard, not optional: it covers login, every logged-in page and a new
browser), and browsing events go without any email:
<script>
// In your common template, when the shopper is logged in. Sent once per browser + email per 30 days.
var email = `{email}`;
if (email.indexOf('@') > 0 && email.indexOf('{') < 0) tocadule.identify(email);
</script>At sign-up, call identify once on submit with the boxes the shopper ticked
(subscribed_email / subscribed_sms / subscribed_phone); without them the contact is
created not subscribed. The order page names every buyer with identify right before
their purchase (the snippet skips a repeat for 30 days per browser + email). See Identity & contacts and, in plain language,
Your data.
The event scripts put each value in backticks (`{email}`), so a quote in a value never
breaks the script. A template token your page leaves unfilled (still {…}) is no value:
we drop it. A required field that does not arrive shows as Eksik in the Data centre.
Cart tracking is separate — and PII-free
Send your whole current cart on every change with tocadule.cart(...) (not track).
The latest cart is the source of truth for cart segments, product-in-cart popups, and
abandoned-cart automations. On supported platforms (Shopify, IdeaSoft, WooCommerce, T-Soft,
and any store the universal reader recognises by shape) this is captured automatically.
<script>
// cart: call on every cart change (add, remove, quantity) and on the cart page, with the WHOLE cart. Replace each {…} with your platform's token.
var items = [];
// inside your platform's cart loop, once per product:
items.push({ product_id: `{productId}`, variant_id: `{variantId}`, sku: `{sku}`, name: `{productName}`,
price: `{productPrice}`, quantity: `{productQuantity}`, url: `{productUrl}`, image_url: `{productImage}` });
tocadule.cart({ items: items, subtotal: `{subtotal}`, currency: `{currency}`, cart_id: `{cartId}` });
</script>An empty cart is items: []. No email or other personal data goes on the cart.
Never put an email or other PII on tocadule.cart(). The cart carries only the
anonymous_id and resolves to a contact through the identity map. Keep it lean.
Custom events are welcome
tocadule.track() accepts any event name — you're not limited to the standard set.
A custom event is stored on the events table exactly like a standard one, with all the same
automatic enrichment. It shows up in your Events page (the event stream, and read-only
below the expected events on Sources) and is available as a segment /
automation trigger and in analytics. Standard commerce names
(product_view, add_to_cart, checkout_started, purchase, view_cart,
view_item_list, search) get extra downstream handling — canonical mapping, gap-fill,
and ad-destination forwarding — so prefer them for commerce steps and use custom names for
everything else.
What happens to an event
- Snippet attaches enrichment (UTM, device, traffic source, click IDs, page context)
and
POSTs to/events/trackwith yourworkspace_id, theanonymous_id, and both consent lanes. - Identity — we look up the
anonymous_idin the identity map. An identity event (identify, a popup form) finds or creates the contact and links the browser: for our reports when the analytics lane allows it, for ad sends only when only the advertising lane does. An email on another event is only that event's ad match. - Enrichment — server-side geo (see below) and device / IP are merged into the event as consent allows (values you passed always win).
- Bot check — requests from known bots are flagged
is_bot; analytics and ad forwarding exclude them. - Store — personal data is stripped, then the event is written to the events table.
- Forward — non-bot events are enqueued for server-side delivery to your matched ad destinations (Meta CAPI, TikTok, GA4, Google Ads, ChatGPT Ads), subject to the consent lanes.
Consent: two lanes
Tocadule reads consent from your CMP (Google Consent Mode v2, IAB TCF v2, OneTrust, Cookiebot, Iubenda, GPC…) and treats it as two independent lanes:
| Lane | Field | Gates |
|---|---|---|
| Analytics / general | consent_state | Keeping an anonymous_id on events and linking the browser to a contact for reports: granted only (no answer is not consent). |
| Advertising | ad_consent | Forwarding to ad destinations: full when granted; otherwise nothing, or a count where the destination counts the not-consented. Alone, it keeps the visitor id for the ad match only. |
Marketing permission (email / SMS / phone / WhatsApp) is a separate record on the
contact, set via identify() traits, your forms, popups, Shopify or the panel — it is
not a CMP lane, and no contact is subscribed without evidence.
A banner we do not recognise, or your own consent screen? State the answer:
tocadule.setConsent({ analytics: true, ads: false }) for the visitor; a form of yours states the ads
answer for one event, track(name, props, { consent: { ads: true } }) (an event's analytics is ignored).
Geo & dedup, briefly
- Location comes from MaxMind (offline GeoLite2 City) resolved from the real client IP — the one source for event country / region / city / postal code / timezone (no coordinates). CloudFront's headers are not read. Location segments read the visits' place (resolved from their events' IP).
- Contact profile location is declared-only — set from
identify()traits (country,city), a popup field, CSV or the Shopify address, never inferred from IP. - Dedup is handled for you: browser events dedup on
anonymous_id, external events (Shopify, connectors) onsource_event_id. You never set dedup IDs yourself.
Next steps
- Standard events — the exact
tocadule.track()script for each commerce event. - Server API — sending events from your server: API keys, cancellations and refunds.
- Identity & contacts — identity events, linking, and where personal data lives.
- Your data — for store owners: what we collect, consent, permission, retention.
- Cart tracking —
tocadule.cart(), supported platforms, and cart health. - Consent & privacy — the two lanes, CMP detection, and cookieless mode.
- Destinations — connecting Meta, TikTok, and GA4 for server-side forwarding.