> For the complete documentation index, see [llms.txt](https://docs.thndr.io/integration/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.thndr.io/integration/customisation/analytics-events.md).

# Analytics Events

The THNDR widget emits real-time analytics events to your host application via `postMessage`. These events tell you exactly what a player is doing inside the game - which tabs they're viewing, when matches start and finish, and how they interact with results and leaderboards.

### postMessage event

When a player performs a tracked action, the game emits the following message to the parent window:

```json
{
  "message": "operator_analytics_event",
  "data": {
    "eventName": "MatchStarted"
  }
}
```

The `eventName` field contains the name of the event.

### Example listener

```javascript
window.addEventListener("message", (event) => {
  let data;
  try {
    data = JSON.parse(event.data);
  } catch {
    return;
  }

  if (data.message === "operator_analytics_event") {
    const eventName = data.data.eventName;
    console.log("THNDR event:", eventName);

    // Example: track in your own analytics
    analytics.track("thndr_event", { event: eventName });
  }
});
```

### Event reference

#### Navigation

| Event name             | Description                       |
| ---------------------- | --------------------------------- |
| `GameTabViewed`        | Player viewed the main game tab   |
| `ResultsTabViewed`     | Player viewed the results tab     |
| `LeaderboardTabViewed` | Player viewed the leaderboard tab |
| `RulesTabViewed`       | Player viewed the rules tab       |

#### Matches

| Event name              | Description                      |
| ----------------------- | -------------------------------- |
| `MatchStarted`          | Player started a paid match      |
| `MatchFinished`         | Player finished a paid match     |
| `PracticeMatchStarted`  | Player started a practice match  |
| `PracticeMatchFinished` | Player finished a practice match |

#### Results

| Event name                     | Description                                                |
| ------------------------------ | ---------------------------------------------------------- |
| `MyResultsViewed`              | Player viewed their own results                            |
| `TournamentResultsViewed`      | Player viewed tournament results                           |
| `WorldwideResultsViewed`       | Player viewed worldwide results                            |
| `ResultDrawerWinViewed`        | Player saw the result drawer after a win                   |
| `ResultDrawerLossViewed`       | Player saw the result drawer after a loss                  |
| `ResultDrawerDrawViewed`       | Player saw the result drawer after a draw                  |
| `ResultDrawerCancelledViewed`  | Player saw the result drawer for a cancelled match         |
| `ResultDrawerInProgressViewed` | Player saw the result drawer for a match still in progress |
| `StatsDrawerViewed`            | Player viewed the stats drawer                             |

#### Leaderboards

| Event name                           | Description                                        |
| ------------------------------------ | -------------------------------------------------- |
| `MostWinsDailyLeaderboardViewed`     | Player viewed the daily most-wins leaderboard      |
| `MostWinsWeeklyLeaderboardViewed`    | Player viewed the weekly most-wins leaderboard     |
| `MostWinsMonthlyLeaderboardViewed`   | Player viewed the monthly most-wins leaderboard    |
| `MostWinsAllTimeLeaderboardViewed`   | Player viewed the all-time most-wins leaderboard   |
| `TopEarnersDailyLeaderboardViewed`   | Player viewed the daily top-earners leaderboard    |
| `TopEarnersWeeklyLeaderboardViewed`  | Player viewed the weekly top-earners leaderboard   |
| `TopEarnersMonthlyLeaderboardViewed` | Player viewed the monthly top-earners leaderboard  |
| `TopEarnersAllTimeLeaderboardViewed` | Player viewed the all-time top-earners leaderboard |

#### Other

| Event name       | Description                                                  |
| ---------------- | ------------------------------------------------------------ |
| `BalanceUpdated` | Player's balance was updated (after a win, loss, or deposit) |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.thndr.io/integration/customisation/analytics-events.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
