playgen.io

Documentation

Player events

Integrating Events

Managing Game Events and Leveraging Them for Enhanced Engagement

Game events in playgen.io can be powerful tools for tracking player actions, optimizing user experience, and unlocking new engagement opportunities. Below is a guide on how to handle these events within your platform’s context and ideas on their potential use cases.

Listening for Game Events

To handle game events, listen for specific events dispatched by the playgen.io game iframe. Here’s an example of how to set up an event listener in JavaScript:

window.addEventListener("message", (event) => {
  if (event.origin !== "https://play.playgen.io") return; // Ensure it's from a trusted source
 
  const { type, data } = event.data;
 
  switch (type) {
    case "PLAYGEN_GAME_COMPLETED":
      console.log("Game completed:", data);
      // Custom logic for when a game is completed
      break;
 
    case "PLAYGEN_SHARE_X":
      console.log("Game shared:", data);
      // Custom logic for when the game is shared
      break;
 
    // Add cases for other events you wish to handle
  }
});

Each event carries specific data that can be used to tailor the user experience based on player behavior. For example, you could prompt users with a congratulatory message upon receiving a "PLAYGEN_GAME_COMPLETED" event.

Benefits and Use Cases for Game Events

1. Paywall or Loginwall Integration

Certain game events, like PLAYGEN_GAME_STARTED, PLAYGEN_REQUEST_ARCHIVE, and PLAYGEN_REQUEST_LEADERBOARD, are ideal for controlling access to premium features. You can set up conditions to restrict content unless users log in or pay for access. For example:

  • Loginwall: Require users to log in after they start a game or attempt to view the leaderboard.
  • Paywall: Restrict access to archived games or other premium content until users subscribe or make a one-time payment.

2. Ads Integration

Use game events to dynamically manage ad display based on player actions. For instance, events like PLAYGEN_GAME_COMPLETED or PLAYGEN_GAME_RESET can trigger ad displays, ensuring that ads don’t interrupt gameplay:

  • Interstitial Ads: Display ads between game sessions or after a game is completed.
  • Banner Ads: Show non-intrusive ads when players view the leaderboard or access settings.

3. Lead Generation Forms

Game events can be used to trigger lead generation forms at optimal times during the gameplay experience. For example:

  • End-of-Game Lead Capture: After the PLAYGEN_GAME_COMPLETED event, prompt users with a lead form to capture their contact information in exchange for rewards or special content.
  • Access-Gated Content: Use PLAYGEN_REQUEST_ARCHIVE and PLAYGEN_REQUEST_LEADERBOARD to request users to fill out a lead form before accessing exclusive areas like game archives or leaderboards.

4. Controlling Gated Content

Events such as PLAYGEN_REQUEST_ARCHIVE and PLAYGEN_REQUEST_LEADERBOARD are useful for gating premium content. This allows for:

  • Premium Access Control: Restrict access to archived games or detailed leaderboards as part of a subscription or loyalty program.
  • Feature Trials: Offer temporary access to gated features based on specific user actions, such as completing a game or sharing a score.

5. Real-Time Analytics and Feedback

Monitoring events like PLAYGEN_GAME_RESET, PLAYGEN_OPEN_ARCHIVE, and PLAYGEN_GAME_OPEN_INSTRUCTIONS provides valuable feedback on where players may struggle or need assistance. This insight can be used to:

  • Refine Game Instructions: If many players open the instructions repeatedly, consider adding in-game tips or simplifying complex features.
  • Identify Popular Content: By tracking archive or leaderboard accesses, you can identify the most frequently viewed or revisited games.

By incorporating game event handling, you can not only improve the user experience but also gain valuable insights into player preferences and behaviors. These events offer a foundation for creating a more engaging, tailored, and data-driven platform experience.

On this page