playgen.io

Documentation

Cross platform

Player ID & Username

Using Hashed User IDs for Consistent User Identification

playgen.io provides cross-platform support, allowing clients to maintain a consistent user experience across multiple devices. By sending a hashed user ID and/or a username, clients can ensure that players are identified consistently on leaderboards and other user-specific features, even when switching between platforms. This section covers how to configure cross-platform support securely while ensuring user privacy.

How to Use Hashed User IDs and Usernames

  1. Sending a Hashed User ID:

    • Clients are encouraged to send a unique, hashed user ID to identify players. This ID allows playgen.io to maintain consistency in user-specific data, such as leaderboard positions, across multiple platforms and devices.
    • If no user_id is provided, playgen.io will generate a random ID for the session. However, to enable cross-platform consistency, it’s recommended to provide your own hashed ID.
  2. Using the PLAYGEN_SESSION_INIT Event:

    • To initialize cross-platform support, send a PLAYGEN_SESSION_INIT event with the user_id (hashed) and username (optional) parameters. However, this event should only be sent after playgen.io has dispatched the PLAYGEN_SESSION_LOADED event.
    • Here’s an example:
    window.postMessage(
      {
        event_name: "PLAYGEN_SESSION_INIT",
        user_id: "hashed_unique_user_id",
        username: "Player123",
      },
      "https://play.playgen.io"
    );
  3. Wait for PLAYGEN_SESSION_LOADED Event:

    • The PLAYGEN_SESSION_LOADED event is dispatched by playgen.io to indicate that the game instance has been fully loaded and is ready for session initialization.
    • The function responsible for sending this event is as follows:
    export function sendSessionLoadedEvent({ instance }) {
      const { publish_key, game_type, title } = instance;
     
      const payload = {
        event_name: "PLAYGEN_SESSION_LOADED",
        publish_key: publish_key,
        game_name: game_type,
        title: title,
        created_at: new Date().toISOString(),
        timestamp: new Date().getTime(),
      };
     
      window.parent.postMessage(payload, "*");
    }
    • Only after receiving this event should you proceed to send the PLAYGEN_SESSION_INIT event with your hashed user_id and username.
  4. Privacy Considerations:

    • No PII Storage: playgen.io is committed to user privacy and does not store any personally identifiable information (PII). The user_id should be a hashed or anonymized value, ensuring it cannot be traced back to an actual user.
    • Random ID Generation: If no user_id is sent, playgen.io will generate a unique ID for each session. However, this ID will not support cross-platform consistency, so we recommend providing your own hashed ID.

Benefits of Cross-Platform Support

Implementing cross-platform support offers several benefits:

  • Consistent User Experience: By using a hashed user_id, users will see consistent scores and rankings on the leaderboard, regardless of the device they use to play.
  • Enhanced User Retention: Persistent IDs allow for features like saved progress, which can help increase user retention by allowing players to pick up where they left off on any device.
  • Improved Engagement Tracking: With a consistent user_id, you can track user engagement more effectively, gaining insights into player behavior across devices.

Testing Cross-Platform Support

You can test cross-platform support and debug your integration in the Playground section of the game editor. Here, you can monitor the events sent and received, ensuring your hashed IDs and usernames are functioning correctly across different platforms.

By following these guidelines and waiting for the PLAYGEN_SESSION_LOADED event, you can implement a secure, privacy-focused cross-platform solution that provides a seamless experience for your users on playgen.io.

On this page