Integrating Events
Managing Game Events and Leveraging Them for Enhanced Engagement
Game events in Playgent 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 Playgent 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.playgent.com") return; // Ensure it's from a trusted source
const { event_name, data } = event.data;
switch (event_name) {
case "PG_GAME_COMPLETED":
console.log("Game completed:", data);
// Custom logic for when a game is completed
break;
case "PG_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 "PG_GAME_COMPLETED" event.
Benefits and Use Cases for Game Events
1. Paywall or Loginwall Integration
Certain game events, like PG_GAME_STARTED, PG_REQUEST_ARCHIVE, and PG_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 PG_GAME_COMPLETED or PG_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
PG_GAME_COMPLETEDevent, prompt users with a lead form to capture their contact information in exchange for rewards or special content. - Access-Gated Content: Use
PG_REQUEST_ARCHIVEandPG_REQUEST_LEADERBOARDto request users to fill out a lead form before accessing exclusive areas like game archives or leaderboards.
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.