Revenue
Link users to visits
After a user signs in, your backend links your own stable user ID to the browser's visitor ID.
Identify a user
Read the visitor ID in the browser
Call
window.analytics.getVisitorId()and send the result to your backend with the signed-in request.Call Identify from your backend
Set
METRICRAVEN_SECRET_KEYin your server environment first. Use your own user ID, not a MetricRaven dashboard account ID.Server terminal · replace example valuescurl --request POST 'https://metricraven.com/api/v1/identify' \ --header "Authorization: Bearer $METRICRAVEN_SECRET_KEY" \ --header 'Content-Type: application/json' \ --data '{ "visitor_id": "0123456789abcdef0123456789abcdef", "user_id": "user_42", "email": "ana@example.com", "name": "Ana" }'Reuse the same user ID everywhere
Use the same user ID in your payment provider metadata and server events.
Verify it works
In Traffic, open Visitors for a period that includes the visit and search for the user's email or your user ID. Their journey joins visits, goals and payments.
Details
getVisitorId()can returnnulluntil the first collection request completes. Retry after the browser'sanalytics:visitorevent, or defer linking until an ID is available.- Don't send the literal example visitor ID.
- Email and name are optional.
- The browser supplies the visitor ID; your backend supplies the authenticated user ID. Never trust a user ID sent from the browser.