How to get Analytics from the Web Playable?

This article is a how-to get analytics event data from Pley web games when you're building a web gaming destination.

Use Web SDK 2's onEvent constructor option to receive events from the playable on your website. Your handler can forward relevant events to the analytics service you use.

First configure your distribution channel and load the SDK as shown in Web SDK setup.

const playable = new Pley.WebSdk(
  "game-container",
  "YOUR_DISTRIBUTION_ID",
  {
    onEvent: (event) => {
      console.log("Pley event:", event);
      // Forward relevant events to your analytics integration here.
    },
  }
);

If you already create the playable elsewhere, add onEvent to that instance's options rather than creating another playable just for analytics. Keep any authentication, ad, and payment callbacks required by your channel alongside it.

Inspect the events your integration receives and map them to your analytics provider's event format. SDK2 does not require the earlier createPlayable() / addEventHandler() pattern. A data-layer integration is something you implement in this callback; receiving an event does not automatically forward it to your analytics provider.

See List of Pley Analytics Events for the documented gameplay events. Dispose of the playable when its host component is removed.