Sign inGet started
Tracking

Segment and RudderStack

View as MarkdownOpen in ChatGPTOpen in Claude
Connect your agent
Add to CursorAdd to VS Code

Forward your CDP's calls from Segment or RudderStack, so the user ids it already knows join your people and an alias merges two profiles into one.

Updated

A customer data platform (CDP), such as Segment or RudderStack, already knows who your users are: it sends identify when they sign in and alias when an account changes. Forward its calls to nextanalytica, and those user ids join your people, so your agent reads one person where it would see several.

This works next to the tag, not instead of it: the tag counts visits, and your CDP adds the ids and events only it has.

What do you need?

  • A server key. An owner or admin opens Tracking and, under Keys, clicks Make one (or New key) next to Server key. It's shown once, so copy it then. It's the same key your servers use for server events; a new key stops the old one at once, everywhere.
  • The address: https://t.nextanalytica.app/cdp.

Set up Segment

  1. In Segment, add the Webhooks (Actions) destination to the source you want to forward.
  2. Add a mapping with the Send action, for the calls you want: Identify, Track, Page, Group and Alias.
  3. Set URL to https://t.nextanalytica.app/cdp and Method to POST.
  4. Under Headers, add Authorization with the value Bearer nask_…, your server key.
  5. Send the whole event as Data, as Segment writes it.
  6. Turn the destination on.

Batching can stay on: one request takes up to 1,000 calls and 4 MB.

Set up RudderStack

  1. In RudderStack, add the Webhook destination and connect your source.
  2. Set the URL to https://t.nextanalytica.app/cdp and the method to POST.
  3. Add the header Authorization with the value Bearer nask_…, your server key.
  4. Send the event payload as it is.

What does each call become?

Each call becomes one event of the person it names: userId when it has one, else anonymousId.

CallBecomesWhat's kept
identify with a userIdThe anonymousId is linked to the userId: that person's earlier events become the signed-in person'sUp to 20 traits, as person properties
identify with an anonymousId onlyThat person's properties changeUp to 20 traits
trackA custom event, named as the call's eventUp to 10 properties; revenue or value, with currency, as the event's value
track named Order CompletedAn orderorder_id, revenue (or total) and currency
pageA page view of the personThe path without its query, the host and the title
groupThe person joins a group of type company, keyed by groupIdUp to 20 traits, as the group's properties
aliasThe previousId is merged into the userId: two people become oneNothing more

Properties and traits are kept as text: words, numbers and true or false. Nested objects and lists are left out, and each value is cut at 500 characters.

Other calls, such as screen, and calls with no id are skipped; the rest of the request is kept. The answer says how many of each: {"accepted":6,"skipped":1}.

How do the CDP's ids meet the tag's?

Through your user id. Segment's anonymousId isn't the tag's visitor id, so an anonymous visitor seen by both is two people until they sign in. Call identify in the tag with the same user id your CDP sends, and both histories become one person. See Identify people.

alias merges two people even when both had signed in: the userId survives with every id the previousId had.

Do these events count as visits?

No. Like server events, each call is an event of its person that belongs to no visit, so nothing is counted twice when the tag runs too. Orders and conversions from your CDP count under the channel "Server". Visits, pages and channels still come from the tag.

Every call your CDP forwards counts as consented: your CDP is where consent is decided, as on your own servers. Set up your CDP's consent settings so calls from people who said no never reach this destination.

Do Not Track and Global Privacy Control aren't checked for these calls, because they come from your CDP, not from a browser.

What is never kept?

  • IP addresses. context.ip is ignored, and the request's own address is your CDP's, never stored.
  • The rest of context: the user agent, the location, the device and the library.
  • Query strings. A page's path loses its query, and emails, tokens, card-like numbers and phone numbers in the path are replaced.

Traits are your data: a trait that is an email address is kept as a person property. Other text, in traits, properties and titles, loses emails, tokens, card-like numbers and phone numbers. Never send passwords.

What time does an event get?

The call's timestamp, else originalTimestamp or sentAt. A time more than a day from now gets the time it arrived instead, so this isn't a way to import old history.

A call your CDP retries, with the same messageId and timestamp, counts once.

What do the answers mean?

StatusMeaning
200Taken. The body says how many calls were accepted and skipped.
400Not JSON, or no calls, or more than 1,000 in one request.
401The Authorization header is missing, or the server key is unknown. Make a new one in Tracking.
413The request is over 4 MB. Turn the batch size down.
429Too many requests for one project: over 3,000 in 10 seconds. Your CDP retries.

Next steps

Related
  • What the tag collects: Page views, clicks, forms, scroll, errors and page speed, counted without code. What never leaves the page.
  • Add the tag: Put one script line in the head of every page. Where it goes in plain HTML, site builders and each framework.
  • Cookieless counting and consent: The tag counts without cookies until a visitor agrees. How consent works, from your banner or your code.
  • Custom events: Send your own events and orders, such as sign-ups, demo requests and purchases, with one line of JavaScript each, so revenue ties to the visit.
  • Identify people: Name signed-in people with identify, so their visits on every device make one profile your agent can read. It works only after the visitor's consent.
  • Subdomains, domains and Safari: Keep one visitor across your subdomains and your other domains, and stop Safari from forgetting returning visitors after 7 days.
Still have questions?
Was this page useful?