Skip to content
All postsAttribution

The most important line of analytics code you will write

If you only add one line of tracking code beyond the snippet, make it this one:

js
reveata('identify', { userId: 'user_123', email: '[email protected]' });

Called when a person signs in to your product, it tells Reveata that this browser belongs to a known user. It sounds minor. In practice, it is what keeps revenue attribution working when the easy path breaks: a checkout that cannot carry the visitor id, a cookieless setup, a payment made long after the first visit. This post explains why, and how to use it carefully.

The problem identify solves

Analytics recognises browsers, not people. By default, the Reveata script keeps a random visitor id in a first-party cookie, so the same browser is the same visitor on later visits. That breaks in several ordinary situations:

  • A second device. Someone reads your blog on their phone, then signs up on their laptop. Two visitors.
  • A checkout without the visitor id, such as a payment link sent by email or opened from another app.
  • A second browser, or a cleared cookie. A new visitor.
  • Safari, which keeps cookies set by a script for at most seven days. A buyer who returns after two weeks is a new visitor.
  • Cookieless mode, where a visitor lasts one day. See The case for cookieless analytics in 2026.

Each break cuts the link between the visit that found the customer and the payment they make later. Payments still count in your revenue, but as unattributed, or credited to the wrong visit.

What identify does

When you call identify with a stable userId, the visitor is linked to that user. Their earlier anonymous visits on that browser stay linked to them, and payments are matched to the right visitor through the user id or the email. In Reveata's matching order, a payment is linked by the visitor id in the checkout metadata first, then the session id, then the user id from identify, then the email of an identified visitor, then the customer's earlier payments. See How revenue attribution works.

So identify is the fallback that catches what checkout metadata misses: a payment link sent by email, a checkout opened from another app, a renewal months later. It also matters in cookieless mode, where there is no visitor id in the browser to put in the checkout at all.

What identify cannot do is see visits it was never told about. If someone found you on their phone and never signed in there, that phone visit stays a separate, anonymous visitor. Identify links the visitors where the person did sign in.

Identified visitors also show their name on their visitor profile, with the custom properties you sent, so a journey reads as a person rather than a random id.

What to send

js
reveata('identify', {
  userId: 'user_123',      // required: your own stable id
  email: '[email protected]', // optional, helps payment matching
  name: 'Ada Lovelace',     // optional
  plan: 'pro',              // anything else becomes a custom property
});
  • userId is required. Use your database's id for the user, not the email, so it never changes. Calls without it are ignored.
  • email is optional but valuable: many payment providers record the buyer's email, so it gives Reveata a second way to match a payment.
  • Extra keys become custom properties (string values, up to 20), useful for filtering profiles.

Call it once after sign-in, or on every page load while the person is signed in. Both work. The reference is in Identify visitors.

Where to call it

  • After sign-in and sign-up, in the browser, on the first page the signed-in user sees.
  • In your app's layout, if it is simpler to call it on every page while signed in.
  • From your backend, through the API with a key that has identify:write, if you want the identity marked as verified so payment matching can trust it, or to set a profile picture. The browser call cannot set a picture, because anyone can call identify from a browser.

Be careful with it

Identify attaches a real person to analytics data, so it deserves some thought.

  • Only identify people when your privacy policy allows it, and describe it there. Whether you need consent depends on your configuration and your visitors' countries; ask your adviser. See Privacy, cookies and cookieless mode.
  • Send only what you need. A user id is enough for matching. Email helps. Most other fields are optional.
  • Mind who can see names. When revenue is hidden from viewers, they see "Name and email hidden by the site admin" instead. See Team and roles.
  • Honour requests. When a person asks for a copy of their data or for deletion, Visitor data requests covers how.

Because anyone can call identify from a browser, Reveata has a setting that controls whether browser identify calls are trusted for payment matching: Match payments using browser identify calls in Settings → Payments. It also governs the email form of reveata('payment', { email }) on thank-you pages. If you prefer to trust only identities your server confirms, identify from the backend instead.

How to tell whether you need it

Open your payments and look at how many are unattributed. If the share is significant, identify is usually the fix, alongside passing the visitor id at checkout. Link payments to visits with identify walks through diagnosing it.

The short version

  • Analytics recognises browsers; identify tells it about people.
  • One call after sign-in links that visitor, and the payments made with the same user id or email, to your user.
  • It is the fallback that keeps attribution working when the checkout carries no visitor id, including in cookieless mode.
  • Send a stable user id, and an email if you can.
  • Treat it as personal data: describe it, limit it, and honour requests.