RoadwayDocs

Identity and IDs

Roadway credits a channel only if it can follow a customer from ad click to payment.

Each system records the customer under a different identifier. Identity is the work of making those identifiers line up.

To set the IDs, see Tracking sources, Capture IDs in forms and Choose a revenue model.

The four IDs

ID Identifies Typical value Column in Roadway tables
anonymousID A browser or device before the person is known GA4 user_pseudo_id, Segment anonymousId, PostHog $device_id visitor_id
userID A person who signed up or logged in to your product Your database's user primary key user_id
customerID A billing account Stripe cus_... customer_id
contactID A record in your CRM HubSpot contact ID or Salesforce record ID contact_id

How the IDs connect

A single customer typically carries all four IDs over time:

   ad click ─► visit ──────────► form fill ─────► sign up ──────────► payment
              anonymousID         contactID        userID              customerID
              (browser)           + anonymousID    (+ anonymousID)     + userID
                                  (hidden field)   (identify call)     (billing metadata)
  • The anonymousID links a visit to a form fill, because the form stores it in a hidden field. The optional Roadway tag can fill that field.
  • The userID links a visit to a sign-up, because page views after login carry both IDs, and Roadway copies the userID back onto the browser's earlier page views.
  • The userID links a sign-up to a payment, because it's stored with the customer in billing.

The ID at each join must be the same value, in the same format, in every system. 42, "42", and user_42 are three different IDs.

Which tables need which IDs

See Required IDs by table. It lists the IDs each table needs, and what required means for attribution.

What happens when an ID is missing

Roadway still loads the row, but the row can't be linked to the rest of the journey. Users with no matched visit, and transactions and recurring-revenue customers whose user_id doesn't match a user, are reported under channel No tracked visit (traffic source Unknown, campaign N/A). See Identity resolution for the rest.

Where to go next

  1. Read Anonymous ID, User ID, Customer ID, and Contact ID.
  2. Read Identity resolution to see how the joins work and where they break.
  3. Use the ID crosswalk to translate between Roadway's terms and each vendor's.

Anonymous ID

An anonymous ID (anonymousID) identifies a browser or device before you know who the person is.

Your analytics tool creates it automatically on the first visit and stores it in a cookie or local storage. In Roadway's tables it's called visitor_id.

Why Roadway needs it

The anonymous ID is the thread that connects pre-signup behavior (ad clicks, page views, blog reads) to later records. Roadway uses it in two places:

  • Sessions. Every page view carries a visitor_id. Roadway groups page views into sessions and reads UTM parameters, referrers, and landing pages from them.
  • CRM. When someone fills out a form, a hidden field stores their anonymous ID. The optional Roadway attribution tag can fill it. That value becomes the contact's visitor_id (or, for HubSpot forms in an iframe, the link comes through the HubSpot form-submission event), which joins the contact to their earlier visits.

Where each tool stores it

Tool Name Where to read it Example
Google Analytics 4 user_pseudo_id (also called client ID) _ga cookie, or user_pseudo_id in the BigQuery export 1234567890.1700000000
Segment anonymousId analytics.user().anonymousId(), or anonymous_id in warehouse tables 8e2f6d51-0f6f-4b3e-9b2a-6c1f5ad7b0c4
PostHog $device_id; Roadway's visitor_id (falls back to distinct_id) posthog.get_property('$device_id'), or the ph_<token>_posthog cookie or local storage entry (ph_<persistence_name> when that option is set) 0190a0c3-7c1e-7b0e-8d5e-2f6a4f1d9c11

The _ga cookie looks like GA1.1.1234567890.1700000000. The last two dot-separated parts are the client ID, which GA4 exports as user_pseudo_id. The Roadway tag reads exactly those last two parts.

When an anonymous ID changes

A visitor gets a new anonymous ID when:

  • They clear cookies or local storage, or use a private window.
  • They switch browsers or devices.
  • Your code resets the identity. In Segment, analytics.reset() clears anonymousId, and analytics.identify() with a different userId than the cached one generates a new anonymousId.
  • A cookie expires or a browser's tracking prevention shortens its lifetime.

When the ID changes, earlier visits and later visits look like different people. Roadway links two anonymous IDs only if each has a page view carrying the same user ID.

Roadway requirements

  • visitor_id must be present on every page view row. See Page views.
  • Use the same ID in your page views and in the CRM hidden field. For example, don't send Segment's ID to the CRM if your page views come from GA4. Roadway's tag fills fields for GA4, Segment, and PostHog separately, so match the field to your sessions source.

Vendor docs: GA4 BigQuery export schema, Segment: managing identity in Analytics.js, PostHog: identity resolution

User ID

A user ID (userID) is the stable identifier your product assigns to a person when they sign up.

It's the most important ID in your Roadway implementation, because it's the bridge between marketing data (visits), product data (users), and billing data (revenue).

Choose your user ID

Use the primary key of the user record in your application database, or another value that:

  • Never changes for a person.
  • Is unique to one person. If two people share a value, their data merges.
  • Isn't PII. Don't use an email address, name, or phone number. Roadway doesn't use PII, and Google Analytics forbids sending it as a user ID.
  • Is available everywhere. Your frontend, backend, billing integration, and MMP SDK must all be able to read it.
  • Has one format. Always send it as a string with the same formatting. 42 and "042" don't match.

Where the user ID must appear

System What to do Guide
Analytics (web) Send it at sign-up and login GA4, Segment, PostHog
Users table Make it the primary key user_id Users
Billing Store it in the Stripe customer's metadata under user_id (or tell Roadway your key). Checkout-session metadata and client_reference_id aren't read by default. Pass userID to Stripe
CRM (optional) Store it as a contact property Set up your CRM
Mobile SDK Set it as the custom user ID Mobile attribution

Rules that prevent most problems

  1. Set it as soon as you know it. Set the user ID right after sign-up and on every page load for logged-in users. Page views that carry the user ID are how Roadway links visits to the user.
  2. Don't send it for anonymous visitors. In GA4, don't send user_id until the person is signed in.
  3. Clear it on logout. In GA4, set it to null. In Segment and PostHog, call reset().
  4. Use the same value everywhere. A mismatch between your analytics tool and your billing system is the most common reason revenue shows as unattributed.

Vendor docs: GA4 user IDs, Segment: best practices for identifying users

Customer ID

A customer ID (customerID) identifies a billing account.

In Stripe it looks like cus_NffrFeUfNV2Hib. In Roadway's revenue tables it's customer_id.

Customer vs. user

A user is a person who uses your product. A customer is the entity that pays. They're often the same, but not always:

Situation Users Customers
Single-person subscription 1 1
Team plan with five seats 5 1
Parent company with several workspaces many 1

For this reason, Roadway's revenue tables carry both IDs. customer_id says who paid. user_id says which user to credit for acquiring that customer.

Where Roadway uses it

  • In dim__customers, customer_id is the primary key and each customer has a user_id.
  • In recurring revenue, fact__customer_arr_snapshot is keyed by (customer_id, subscription_id, date_day).
  • In transactional revenue, every row in fact__transactions carries a customer_id. If the user pays directly, set customer_id to the user_id.

Roadway attributes each customer to the acquisition touchpoints of the user who paid, so the user_id on the customer matters as much as the customer ID itself.

Requirements

  • customer_id must be unique per customer and consistent across all revenue tables.
  • Each customer should map to a user_id that exists in your Users table.
  • With Stripe, customer_id is the Stripe customer ID. Store your userID in the Stripe customer's metadata under the key user_id. See Pass userID to Stripe.

Contact ID

A contact ID (contactID) identifies a lead or contact record in your CRM.

In HubSpot, it's the contact's record ID. In Salesforce, it's the 18-character record ID (Id) of the contact, or of the lead when Roadway models your funnel on Leads. In Roadway's CRM tables it's contact_id.

Why Roadway needs it

CRM records track sales-led funnels: leads, opportunities or deals, and pipeline. To credit marketing for a deal, Roadway must connect the deal's contact to the contact's earlier website visits. The contact ID identifies the CRM record. The anonymousID stored on that record (as visitor_id) connects it to visits.

 visit (visitor_id) ◄──── dim__contacts.visitor_id ──── contact_id ──── opportunity / deal

How Roadway attributes a deal

A deal can have several contacts. In HubSpot, Roadway credits each deal to its oldest associated contact. In Salesforce, it uses the opportunity's primary contact (Opportunity.ContactId). Keep the right contact associated with each deal.

Requirements

  • contact_id is the primary key of dim__contacts.
  • visitor_id should be filled for as many contacts as possible. It's nullable in the schema, but contacts without it can't be tied back to visits. See Capture IDs in forms. If your CRM stores your userID, Roadway can join on it.
  • dim__opportunities.contact_id must reference a contact in dim__contacts.