On-site personalization
Your site already knows who is looking at it. This is how you use that.
A visitor who has bought three times shouldn't see the same "10% off your first order" banner as someone who arrived from an ad five seconds ago. With one HTML attribute, they don't.
How it works
When an event arrives, we already have the customer's profile in hand — so we evaluate your segments right there, at the edge, and stamp the result into a first-party cookie on your own domain. The next page load reads that cookie synchronously, with zero requests.
That last part is the whole point. The usual way to personalize is to load the page, ask a server who the visitor is, then swap the content — which is why personalized pages flicker: you see the generic version first, then it changes. Here there is nothing to wait for.
The membership is refreshed on each event, so it can be one event behind — someone who becomes a VIP mid-session sees it on their next page. For anything where that matters, read it server-side (see below).
Use it without writing code
Put the attribute on any element:
<!-- only VIPs see this -->
<div data-srf-audience="a3f2b1c4">
Free express shipping on this order.
</div>
<!-- everyone EXCEPT VIPs sees this -->
<div data-srf-audience-not="a3f2b1c4">
Spend $50 more for free shipping.
</div>
The id comes from Segments — each segment shows its own, with a copy button.
Elements with these attributes are hidden before the first paint and revealed only if they match, so there is no flash of the wrong content. Content added later (SPAs, reactive storefronts) is handled too.
Use it from JavaScript
SetRoasFlow('audience') // { segments: ['a3f2b1c4'], known: true }
SetRoasFlow('audience', 'a3f2b1c4') // true | false
known: false means we have not evaluated this visitor yet — typically their very first pageview. Treat it as "not in any segment" rather than as an error.
Turning it off
Personalization runs by default. To disable it:
SetRoasFlow('init', 'YOUR_TOKEN', { personalization: false })
Ideas that actually move numbers
Stop discounting people who already buy. Hide the first-order coupon from repeat customers — you're currently paying for margin you didn't need to give away.
Free-shipping threshold that knows the customer. Show the progress bar to people below their usual basket, not to the ones who always clear it anyway.
Win back quietly. Visitors in an "inactive 90 days" segment see a returning-customer message instead of an acquisition one.
Skip the newsletter modal for people already in your list. It's the fastest way to stop annoying your best customers.
Security: what this cookie is, and is not
The cookie is signed, so nobody can invent a segment they don't belong to by editing it. But a signed cookie can still be copied from one browser to another.
So the rule is:
The audience cookie is a presentation hint. Anything worth money — a discount, a price, access to a page — must be verified on your server.
For that, call the endpoint. It reads the HttpOnly cookie the browser sends automatically, which JavaScript cannot touch:
GET https://YOUR_DOMAIN/audience/YOUR_TOKEN
→ { "ok": true, "segments": ["a3f2b1c4"] }
Use the attribute to change what people see. Use the endpoint before you change what they get.
Privacy
The cookie holds only short segment ids — never an email, never a profile id, never a lifetime value. Anyone reading it learns "this browser is in segment a3f2b1c4", which means nothing without your dashboard.
Where consent is required and hasn't been given, no cookie is written and no personalization happens. That is intentional.
Platform notes
WooCommerce and custom sites — works out of the box; the snippet sits in <head>.
Shopify — the Web Pixel runs in a sandbox with no DOM access, so personalization cannot come from it. It has to run in your theme, through the SetRoasFlow theme app extension.
Get notified instead
Sometimes you don't want to change the page — you want to know. Any segment can send an alert the moment a customer enters it: turn on Notify on entry in Segments, and set your channel under Alerts. Slack gets a message while they're still browsing.