Skip to content

Identity verification

Without identity verification, anyone who knows a user’s ID can call identify with it from their own browser and see that user’s content and history. Identity verification closes that gap. Your server signs each user ID with a secret only you and UserGuiding know, and UserGuiding rejects any identify call whose signature does not match.

  1. You turn on identity verification in the panel and receive a secret key.
  2. For each signed in user, your server computes user_hash, an HMAC SHA256 of the user ID keyed with the secret, encoded as hex.
  3. Your frontend passes user_hash to identify along with the user ID.
  4. UserGuiding recomputes the hash and only accepts the request when the two match.

Get your secret

In the panel, go to Installation > User Identification and click Enable Identity Verification. Copy the secret key it shows.

Generate the hash on your server

Compute the hash from the exact user ID string you pass to identify. If your IDs are numbers, hash their string form, for example "42".

import crypto from 'node:crypto'
const userHash = crypto
.createHmac('sha256', process.env.USERGUIDING_IDENTITY_SECRET)
.update(String(user.id))
.digest('hex')

Generate the hash on each page load or sign in and send it to the frontend. Do not store it in your database. If you rotate the secret, stored hashes all break at once.

Pass the hash to identify

window.userGuiding.identify(user.id, {
email: user.email,
user_hash: userHashFromServer,
})

Check the installation

Back in the panel, click Check Installation. Once the check passes, identity verification is enforced for your project.

  • An identify call without a user_hash is refused, and the SDK logs user_hash is required when identity verification enabled to the console.
  • A call with the wrong hash is rejected by the server, so no content loads for that user.
  • Hex digests are compared case insensitively, so uppercase output (for example from .NET’s BitConverter) also works.
  • Call clearIdentity on sign out to remove the stored hash from the browser.