Embedding

Identity

Tag every event and webhook with your own user ID so completions can be joined back to your warehouse, your auth system, or your CRM.

externalUserId & externalUsername

Two optional, publisher-supplied fields:

  • externalUserId — string, max 128 chars. Your own stable user identifier.
  • externalUsername — string, max 64 chars. A display name. Optional; useful in leaderboards.
js
Playgent.init({
  containerId: "playgent-host",
  game: "sudoku",
  mode: "daily",
  externalUserId: "u_abc123",
  externalUsername: "alice",
});

Where they show up

  • In every event payload: onStart, onComplete, onView.
  • In the analytics stream tied to the player.
  • In game.completed webhooks (if configured).
  • In leaderboard entries when the player participates.

Setting them after init

If your auth state changes mid-session (modal login, etc.), push the new identity:

js
player.setIdentity({
  externalUserId: "u_abc123",
  externalUsername: "alice",
});

The next event the SDK emits will carry the updated values.

Trust model

externalUserId is untrusted — you set it client-side. Treat it as a hint that lets you correlate Playgent events to your records, not a security claim. For high-trust scenarios (rewards, gating), verify completions server-side via a signed webhook.

Anonymous users

Leave both fields empty for anonymous play. The SDK still emits all events; identity fields are simply null.