User Identification
Associate the current browser with a known user (similar to PostHog’s identify). Call once after login or signup; every later push() automatically includes the person context.
Prefer usertrax.identify() as the single call site: when the feedback widget is also on the page, the same call identifies the visitor there too (hides the email field, attaches user metadata). Identity is persisted in localStorage (usertrax_identify), so the widget picks it up even if it loads after the tracker.
Web (Script Tag)
Section titled “Web (Script Tag)”// After the user signs inusertrax.identify("user_xyz", { email: "jane@example.com", plan: "team", seats: 5,});
// Later conversions inherit user_data + meta snapshotusertrax.push({ event: "purchase", total: 49.99, currency: "EUR" });NPM (ESM)
Section titled “NPM (ESM)”tracker.identify("user_xyz", { email: "jane@example.com", plan: "team",});How it works
Section titled “How it works”- Persistence — Stored in
localStorage(usertrax_identify) and reused across page loads and sessions. user_datamerge — Canonical trait keys (email,phone,phone_number,first_name,last_name,name,customer_id,address) are merged into each conversion’suser_data. The distinct id becomescustomer_idwhen you do not set one explicitly. Fields on a singlepush({ user_data: … })override traits fromidentify.- Full trait snapshot — All traits (including custom keys like
planorseats) are sent on every conversion undermeta_data.$usertrax_identify:
{ "distinct_id": "user_xyz", "traits": { "email": "jane@example.com", "plan": "team", "seats": 5 }}- PostHog — When PostHog is loaded and
usertraxConfig.posthogis notfalse,identifyalso callsposthog.identify(distinctId, traits). - Feedback widget — Dispatches
usertrax:identifyso a loaded feedback widget applies the same identity (also hydrates fromlocalStorageon boot).
Supported trait keys for user_data
Section titled “Supported trait keys for user_data”| Trait key | Maps to user_data |
|---|---|
email | Yes |
phone | Yes |
phone_number | Yes |
first_name | Yes |
last_name | Yes |
name | Yes |
customer_id | Yes |
address | Yes |
| Any other key | meta_data only |
Use setUserData() when you only need Google Enhanced Conversions hashing without a stable distinct id — see Ads & Enhanced Conversions. Use identify() when you want a persistent person id and traits on all events.