The two IDs
ID | How long it lasts | What it's for |
|---|---|---|
Visitor (device) ID | 365 days | Recognizes a returning visitor and keeps them in the same test variant on every visit. |
Session ID | Up to 12 hours from the session's start | Groups one visit's pages and events, as shown in Visitor activity and Session replay . |
Both are stored in a first-party cookie named en_ins and in your site's local storage. When the two disagree, the cookie wins. You can change where they're stored with the persistence option in init options.
Read the visitor ID
get_distinct_id() returns the visitor ID. It exists only once the SDK has loaded, so call it from the loaded callback:
entailInsights.init('YOUR_SITE_TOKEN', {
disable_decide: false,
loaded: function (sdk) {
var visitorId = sdk.get_distinct_id();
// e.g. store it with your own lead or order
document.querySelector('#entail-visitor-id').value = visitorId;
},
});Later on the same page, once loaded, window.entailInsights.get_distinct_id() works too.
Use it to connect CROforce to your own data — save it with a lead in your CRM, or with an order in your database — then look the visitor up in Visitor activity.
HubSpot forms fill it in for you
Add hidden fields with these internal names to a HubSpot form, and CROforce fills them when the page loads:
Hidden field name | Filled with |
|---|---|
| The visitor ID |
| The session ID |
Across subdomains
The en_ins cookie is set on your root domain (.example.com), so www.example.com, shop.example.com and try.example.com all see one visitor and one session. That matters for redirect tests that send visitors to another subdomain: the conversion on the destination is credited to the same visitor.
- Another domain (from
example.comtoexample-shop.com) can't read the cookie, so the visitor gets new IDs there. - On
*.herokuapp.comthe cookie stays on the exact subdomain, because browsers don't allow cookies on shared hosting domains. - To keep the cookie on the exact subdomain everywhere, pass
cross_subdomain_cookie: false.
When a visitor gets a new ID
- They clear their cookies and site data, or browse in a private window.
- They switch to another browser or device.
- The cookie is older than 365 days (change it with
cookie_expiration). - They opted out on an earlier page: opting out deletes the stored IDs — see Consent and privacy.
Don't call reset(). The snippet's placeholder lists a reset method, but the SDK doesn't support it: a call made before the SDK loads drops the events queued after it and leaves entailInsights unusable on that page, and one made after throws an error.
- Consent and privacy: Stop storing IDs when a visitor declines.
- init options: persistence, cookie_expiration and more.
- Visitor activity: One visitor's journey across visits.
Frequently asked questions
Does the visitor ID contain personal data?
No. It's a random ID created in the browser. It doesn't contain a name, email or IP address.
Will a visitor keep their ID across my subdomains?
Yes. The cookie is set on your root domain, so www.example.com and shop.example.com share the same visitor and session. A different domain can't read the cookie, so it starts a new visitor.
Why does get_distinct_id say it's not a function?
The snippet's placeholder doesn't include it. Call it after the SDK has loaded, for example from the
callback in loaded
.init
