Skip to main content

Identity and Persistence

What Lil Snack remembers about a player depends on two things: the integration tier configured for your partner key, and the identity you pass when a game loads. This page applies to the JavaScript SDK and the Direct Endpoint. Game Direct keeps its own streaks and stats; see that page's Data Persistence section.

Identity inputs​

Players are anonymous by default. You can tell us more about who is playing, but you never have to.

InputSDK/play URL parameterWhat it is
Anonymous IDAutomaticaidA random ID for this browser. The SDK creates it once and keeps it in your page's storage.
User IDidentify(userId)uidYour own stable ID for a signed-in player. Lil Snack can't verify it.
Identity tokensetToken(token)idtA short-lived signed token that Lil Snack verifies. Used by strong-identity integrations.

Use an opaque ID for uid, such as an internal account ID or a hash of one. Never send an email address or other personal information.

Integration tiers​

Your Lil Snack contact sets your tier when your partner key is created. Every tier is a fully supported, long-term option; pick the one that matches the features you need.

TierNameWhat's rememberedWho the player is
D0EphemeralNothing beyond the current visit.Always anonymous. uid and idt are ignored.
D1LocalThe player's results on this browser, kept in your page's storage through the storage bridge.The anonymous ID, or uid if you send one.
D2Weak identityThe player's results on our servers, across visits and devices.uid if you send one, otherwise the anonymous ID.
D3Strong identityThe player's results on our servers, across visits and devices, for verified players.The verified token's subject, otherwise the anonymous ID.

What that means for players:

  • Returning players. When a player's result is saved, a game recognizes them when they come back: onReady reports hasPlayed: true, and games that support it show the player's earlier result instead of a fresh start.
  • Crowd results. Mini snacks show each player how everyone else answered. From D1 up, every saved play is added to those results. At D0 players still see the crowd's answers, but their own plays aren't saved or counted.
  • Across devices. Only D2 and D3 follow a player from one device to another, and only when you identify them with the same uid or token each time.

Choosing a tier​

  • D0 suits prototypes and privacy-sensitive placements. There's nothing to build beyond the embed.
  • D1 gives returning players continuity on the same browser with no accounts involved. With the SDK there's nothing extra to build; with the Direct Endpoint you answer storage requests.
  • D2 suits sites with signed-in users who want progress that follows them. Call identify() (or send uid) for signed-in players.
  • D3 is for features where a spoofed identity matters, such as rewards or competitive play. It requires a token-signing setup with Lil Snack.

Things to know​

  • Always send the anonymous ID. The SDK does this for you. With the Direct Endpoint, a missing aid means anonymous plays aren't saved at D1, D2, or D3, and nothing about the game tells you so.
  • Identity is captured at load. identify() and setToken() apply to games loaded after the call. A game already on the page keeps the identity it loaded with. The React component remounts automatically when userId or token changes.
  • A token that fails verification doesn't fall back. At D3, an expired or invalid token means that load saves nothing for the player. It never quietly uses uid instead. Tokens travel in the game URL, so keep them short-lived.
  • Local storage can be cleared. At D1, and for anonymous players at every tier, clearing site data or browsing privately starts the player fresh. That's expected for browser storage.
  • Analytics is separate. allowAnalytics: false turns off Lil Snack's product analytics for the player. It doesn't change what's saved for them, or which events your page receives.

To set up D3, or to change your tier, contact support@lilsnack.co.