Collected IDs
Collected IDs let you carry first-party identifiers that already live in the visitor’s browser — a loyalty ID in a cookie, a CRM segment in localStorage, a campaign ID in the URL — into your server-side pipeline, so any destination can use them. You name exactly what to collect; Datafly.js never reads anything you have not configured.
Once collected, a value is stored under the visitor’s identity and attached to later events automatically, so a one-time read keeps working on events that do not resend it.
What you configure
Each provider is one named value to collect, with:
- Name — the key the value is stored under and referenced by (e.g.
loyalty_id). - Type — where to read it from (see below).
- Type-specific setting — the cookie name, storage key, URL parameter, selector, or endpoint.
- Consent category (recommended) — the value is only collected when that consent category is granted.
- Collection timing — first visit only, or every page load.
- Cache — how long to reuse a collected value before reading again.
Source types
| Type | Reads from |
|---|---|
| Cookie | A named first-party cookie (e.g. _ga, _fbp) |
| Local Storage | A localStorage key |
| Session Storage | A sessionStorage key |
| URL Parameter | A query parameter on the current page |
| JS Variable | A global JavaScript variable by path (e.g. dataLayer.0.user_id) |
| Meta Tag | The content of a <meta> tag |
| DOM Attribute | An attribute on a page element (CSS selector) |
| Fetch | A value returned by a JSON endpoint you control |
An optional parser can post-process the raw value — for example, extract the GA client ID from a _ga cookie, pull a field out of a JSON value, or match a regular expression.
The Fetch type runs in the browser, so it cannot send secret credentials. Use it only for endpoints that are safe to call from the page (your own first-party API, or a partner endpoint that allows it). To enrich from a system that requires an API key, use a server-side enrichment provider instead — that call is made from the cluster, never the browser.
Consent
Set a consent category on every provider that collects advertising- or marketing-related identifiers. When the visitor has not granted that category, Datafly.js skips the provider entirely — nothing is read and nothing is sent. Only collect what your consent notice and legal basis cover, and name each source explicitly; there is no “collect everything” option by design.
Using collected IDs in mappings
Collected values are available to any destination blueprint through the collected_ids.<name> source path:
global:
mappings:
- source: collected_ids.loyalty_id
target: external_id
- source: collected_ids.crm_segment
target: user_properties.segment.valueThis lets GA4, Meta, TikTok, a warehouse, or any other destination receive the identifier without each one reading the browser itself.
In the event payload
Collected values appear on the event under collected_ids:
{
"type": "page",
"collected_ids": {
"loyalty_id": "LP-99831",
"crm_segment": "vip"
}
}After the first event they are retained under the visitor’s identity and attached automatically, so the browser does not need to resend them every time.
A dedicated ID Providers configuration tab in the management UI is on the way. Until it ships, providers are configured with your Datafly account team during onboarding. The collection, storage, and mapping behaviour described here is already live.