> For the complete documentation index, see [llms.txt](https://help.smartico.ai/welcome/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.smartico.ai/welcome/technical-guides/smartico-data-warehouse/smartico-dwh-transactional-views-system.md). Agents can also search and read this documentation through its [MCP server](https://help.smartico.ai/welcome/~gitbook/mcp).

# Smartico DWH \ Transactional views, System

This page describes the transactional views that hold system events created by Smartico: bonuses given by Smartico, dynamic rewards, logins, custom actions and game sessions.

The name of a view is the name of the event with the "tr\_" prefix. For example, the view **tr\_core\_bonus\_given** holds the event **core\_bonus\_given**. Read the general rules of the DWH on the [Smartico Data Warehouse (DWH)](https://help.smartico.ai/welcome/technical-guides/smartico-data-warehouse.md#transactional-tables) page first.

## Rules for all transactional views

* One row is one event. The primary key is **event\_id**.
* Every view is partitioned by **event\_time**. Always filter on it, and do not apply a function to the column in the filter.
* The views keep the events of the last 1080 days.
* A view appears in your dataset after its first event. For example, **tr\_core\_dynamic\_bonus\_issued** appears after the first [dynamic reward](https://help.smartico.ai/welcome/products/general-concepts/dynamic-rewards) is issued.
* Columns that hold the ID of an object (a bonus template, a formula, a casino game) join to the dimension tables named under each view.
* Columns marked "ID of a value" hold a number, not a text. The text of each number is in a lookup view of your dataset, named under each view: see [Text of value IDs](#text-of-value-ids). The numbers can differ between labels and between Smartico environments, so filter by the text through the lookup view, not by a fixed number.
* Game session amounts are in the player's wallet currency. To get the amount in the label currency, divide it by **user\_to\_label\_cur\_rate**. The player's currency is **core\_wallet\_currency** in [j\_user](https://help.smartico.ai/welcome/technical-guides/smartico-data-warehouse.md#query-for-user-profile-details).
* A view can also have old columns that are no longer filled. They are not listed here.

Columns in every view:

| Column                     | Type      | Description                                                                                                                                                  |
| -------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| event\_time                | TIMESTAMP | Time of the event (UTC)                                                                                                                                      |
| ingest\_time               | TIMESTAMP | Time when the event was stored in Smartico                                                                                                                   |
| label\_id                  | INT64     | Label ID                                                                                                                                                     |
| user\_id                   | INT64     | Smartico user ID. Joins to [j\_user\_no\_enums](https://help.smartico.ai/welcome/technical-guides/smartico-data-warehouse.md#query-for-user-profile-details) |
| event\_id                  | INT64     | ID of the event in Smartico. Use it to remove duplicates                                                                                                     |
| user\_to\_label\_cur\_rate | NUMERIC   | Rate from the player's currency to the label currency. Amount in the label currency = amount / user\_to\_label\_cur\_rate                                    |

The tables below list the other columns of each view.

## Text of value IDs

The text of a column marked "ID of a value" is in a view of your dataset. **Joins** under each view names it for every such column:

* For most columns, a view named **lookup\_** plus the name of the column. For example, the text of **core\_user\_last\_session\_browser** is in **dwh\_ext\_xxx.lookup\_core\_user\_last\_session\_browser**.

A lookup\_ view has two columns:

| Column | Type   | Description                  |
| ------ | ------ | ---------------------------- |
| id     | INT64  | The ID that the column holds |
| value  | STRING | The text of the ID           |

* It holds the values of your label and the values shared by all labels.
* It is in your dataset when a transactional view of your dataset has the column.
* A new value reaches the lookup view up to about an hour after it first appears. Use LEFT JOIN, so that the events of a new value stay in your totals; their text is empty until then.
* For a column of type INT64\[] (a list of IDs), use CROSS JOIN UNNEST on the column first, then join each ID.

Logins of the last 7 days per browser

```sql
SELECT L.value AS browser, COUNT(*) AS logins
FROM dwh_ext_xxx.tr_login G
LEFT JOIN dwh_ext_xxx.lookup_core_user_last_session_browser L ON L.id = G.core_user_last_session_browser
WHERE G.event_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 7 DAY)
GROUP BY browser
ORDER BY logins DESC
```

## Bonuses (by Smartico)

For the full details of each bonus (status, amounts, the campaign or mission that gave it), use [j\_bonuses](https://help.smartico.ai/pages/mcM2zhXel1UsJAGRV9lc#dwh_ext_xxx.j_bonuses).

### dwh\_ext\_xxx.tr\_core\_bonus\_given

Smartico gave a bonus to a player. One row per bonus.

**Joins:**

* core\_smr\_bonus\_template\_id → [dm\_bonus\_template](https://help.smartico.ai/pages/mcM2zhXel1UsJAGRV9lc#dwh_ext_xxx.dm_bonus_template) (label\_bonus\_template\_id)

| Column                         | Type  | Description                                                                       |
| ------------------------------ | ----- | --------------------------------------------------------------------------------- |
| core\_smr\_bonus\_template\_id | INT64 | ID of the bonus template                                                          |
| core\_smr\_bonus\_type\_id     | INT64 | Type of the bonus. Same values as product\_bonus\_type\_id in dm\_bonus\_template |

Bonuses given by Smartico in the last 7 days, per bonus template

```sql
SELECT B.internal_name, COUNT(*) AS bonuses
FROM dwh_ext_xxx.tr_core_bonus_given G
INNER JOIN dwh_ext_xxx.dm_bonus_template B ON B.label_bonus_template_id = G.core_smr_bonus_template_id
WHERE G.event_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 7 DAY)
GROUP BY B.internal_name
ORDER BY bonuses DESC
```

### dwh\_ext\_xxx.tr\_core\_bonus\_failed

Smartico tried to give a bonus to a player, and it failed. One row per failed bonus.

**Joins:**

* core\_smr\_bonus\_template\_id → [dm\_bonus\_template](https://help.smartico.ai/pages/mcM2zhXel1UsJAGRV9lc#dwh_ext_xxx.dm_bonus_template) (label\_bonus\_template\_id)

| Column                         | Type  | Description                                                                       |
| ------------------------------ | ----- | --------------------------------------------------------------------------------- |
| core\_smr\_bonus\_template\_id | INT64 | ID of the bonus template                                                          |
| core\_smr\_bonus\_type\_id     | INT64 | Type of the bonus. Same values as product\_bonus\_type\_id in dm\_bonus\_template |

## Dynamic rewards (by Smartico)

The value in **core\_dynamic\_bonus\_amount** depends on the result type of the formula (formula\_result\_type\_id in [dm\_j\_formula](https://help.smartico.ai/pages/mcM2zhXel1UsJAGRV9lc#dwh_ext_xxx.dm_j_formula)):

* bonus amount: the calculated amount of the bonus;
* bonus template: the ID of the bonus template to give;
* points, gems or diamonds: the number to add. It can be negative when the formula allows deductions.

### dwh\_ext\_xxx.tr\_core\_dynamic\_bonus\_calculated

A dynamic reward was calculated for a player. One row per calculated reward.

**Joins:**

* core\_dynamic\_bonus\_formula\_id → [dm\_j\_formula](https://help.smartico.ai/pages/mcM2zhXel1UsJAGRV9lc#dwh_ext_xxx.dm_j_formula) (formula\_id)

| Column                            | Type    | Description                              |
| --------------------------------- | ------- | ---------------------------------------- |
| core\_dynamic\_bonus\_formula\_id | INT64   | ID of the formula                        |
| core\_dynamic\_bonus\_amount      | NUMERIC | Calculated value (see the meaning above) |

### dwh\_ext\_xxx.tr\_core\_dynamic\_bonus\_issued

Smartico started to give a calculated dynamic reward to a player. The event is sent before Smartico knows whether the reward was given. One row per attempt: a reward that is tried again can have several rows.

**Joins:**

* core\_dynamic\_bonus\_formula\_id → [dm\_j\_formula](https://help.smartico.ai/pages/mcM2zhXel1UsJAGRV9lc#dwh_ext_xxx.dm_j_formula) (formula\_id)

| Column                            | Type    | Description                              |
| --------------------------------- | ------- | ---------------------------------------- |
| core\_dynamic\_bonus\_formula\_id | INT64   | ID of the formula                        |
| core\_dynamic\_bonus\_amount      | NUMERIC | Calculated value (see the meaning above) |

### dwh\_ext\_xxx.tr\_core\_dynamic\_bonus\_issued\_success

The platform accepted a dynamic reward that Smartico gave. One row per accepted reward. Only rewards whose formula gives a bonus amount or a bonus template have this event; points, gems and diamonds do not.

The view has only the columns that every view has. It also has the column core\_dynamic\_bonus\_formula\_id, which is always empty.

### dwh\_ext\_xxx.tr\_core\_dynamic\_bonus\_issued\_failed

A dynamic reward was not given: a cap stopped it, or the platform rejected it. One row per failed reward. Only rewards whose formula gives a bonus amount or a bonus template have this event; points, gems and diamonds do not.

The view has only the columns that every view has. It also has the column core\_dynamic\_bonus\_formula\_id, which is always empty.

## Core System & User Actions (by Smartico)

### dwh\_ext\_xxx.tr\_login

A player logged in. One row per login. When Smartico counts a login is explained on the [Events and actions](https://help.smartico.ai/welcome/technical-guides/front-end-integration/extended-integration/events-and-actions#online-offline-login-and-logout-events) page.

**Joins:**

* core\_user\_last\_device\_type → [lookup\_core\_user\_last\_device\_type](#text-of-value-ids) (id)
* core\_user\_last\_session\_browser → [lookup\_core\_user\_last\_session\_browser](#text-of-value-ids) (id)
* core\_user\_last\_session\_os\_name → [lookup\_core\_user\_last\_session\_os\_name](#text-of-value-ids) (id)
* core\_last\_login\_entry → [lookup\_core\_last\_login\_entry](#text-of-value-ids) (id)

| Column                              | Type  | Description                                                                                                                                                                                                                                                                                                                                     |
| ----------------------------------- | ----- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| core\_user\_last\_device\_type      | INT64 | Type of the device. ID of a value; text in lookup\_core\_user\_last\_device\_type                                                                                                                                                                                                                                                               |
| core\_user\_last\_session\_browser  | INT64 | Browser. ID of a value; text in lookup\_core\_user\_last\_session\_browser                                                                                                                                                                                                                                                                      |
| core\_user\_last\_session\_os\_name | INT64 | Operating system. ID of a value; text in lookup\_core\_user\_last\_session\_os\_name                                                                                                                                                                                                                                                            |
| core\_last\_login\_entry            | INT64 | Where the player logged in, as your site reports it with [\_smartico.setLoginEntry](https://help.smartico.ai/welcome/technical-guides/front-end-integration/extended-integration/events-and-actions#last-login-entry-point). ID of a value (your own values; text in lookup\_core\_last\_login\_entry). Empty when your site does not report it |

### dwh\_ext\_xxx.tr\_client\_action

A custom action that your site sent with [\_smartico.action](https://help.smartico.ai/welcome/technical-guides/front-end-integration/extended-integration/events-and-actions#custom-actions-client-action). One row per action.

**Joins:**

* client\_action → [lookup\_client\_action](#text-of-value-ids) (id)

| Column         | Type  | Description                                                                                |
| -------------- | ----- | ------------------------------------------------------------------------------------------ |
| client\_action | INT64 | Name of the action. ID of a value (text in lookup\_client\_action); the names are your own |

### dwh\_ext\_xxx.tr\_gs\_game\_session\_changed

A player switched to another casino game during a game session. The amounts and counts cover the game the player left, and only the play within the inactivity timeout (5 minutes by default) before the switch. Read more on the [Game Sessions](https://help.smartico.ai/welcome/products/general-concepts/game-sessions) page. One row per switch.

**Joins:**

* gs\_game\_old\_id, gs\_game\_new\_id → [dm\_casino\_game\_name](https://help.smartico.ai/pages/FwlimpzjSx9FROVnX5hH#dwh_ext_xxx.dm_casino_game_name) (smr\_game\_id). Cast the column to INT64 for the join

| Column                       | Type      | Description                                                                                         |
| ---------------------------- | --------- | --------------------------------------------------------------------------------------------------- |
| gs\_game\_old\_id            | NUMERIC   | ID of the game the player left                                                                      |
| gs\_game\_new\_id            | NUMERIC   | ID of the game the player started                                                                   |
| gs\_session\_start\_date     | TIMESTAMP | Start of the counted play                                                                           |
| gs\_session\_end\_date       | TIMESTAMP | End of the counted play                                                                             |
| gs\_session\_length\_seconds | NUMERIC   | Length of the counted play, in seconds                                                              |
| gs\_event\_delay\_seconds    | NUMERIC   | Time between the last bet on the game the player left and the first bet on the new game, in seconds |
| gs\_bets\_count              | NUMERIC   | Number of bets                                                                                      |
| gs\_total\_bet\_amount       | NUMERIC   | Total bet amount (real and bonus money)                                                             |
| gs\_avg\_bet\_amount         | NUMERIC   | Average bet amount                                                                                  |
| gs\_max\_bet\_amount         | NUMERIC   | Highest bet amount                                                                                  |
| gs\_wins\_count              | NUMERIC   | Number of wins                                                                                      |
| gs\_total\_win\_amount       | NUMERIC   | Total win amount (real and bonus money)                                                             |
| gs\_avg\_win\_amount         | NUMERIC   | Average win amount                                                                                  |
| gs\_max\_win\_amount         | NUMERIC   | Highest win amount                                                                                  |

### dwh\_ext\_xxx.tr\_gs\_game\_session\_ended

A game session ended: the player made no bets for the inactivity timeout (5 minutes by default). The amounts and counts cover the whole session, across all games. Read more on the [Game Sessions](https://help.smartico.ai/welcome/products/general-concepts/game-sessions) page. One row per session.

**Joins:**

* gs\_all\_game\_ids (each ID) → [dm\_casino\_game\_name](https://help.smartico.ai/pages/FwlimpzjSx9FROVnX5hH#dwh_ext_xxx.dm_casino_game_name) (smr\_game\_id)

| Column                           | Type      | Description                                                                                                                                                           |
| -------------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| gs\_all\_game\_ids               | INT64\[]  | IDs of all games played in the session                                                                                                                                |
| gs\_session\_start\_date         | TIMESTAMP | Start of the session                                                                                                                                                  |
| gs\_session\_end\_date           | TIMESTAMP | End of the session                                                                                                                                                    |
| gs\_session\_length\_seconds     | NUMERIC   | Length of the session, in seconds                                                                                                                                     |
| gs\_event\_delay\_seconds        | NUMERIC   | Time between the last bet and the event, in seconds                                                                                                                   |
| gs\_bets\_count                  | NUMERIC   | Number of bets                                                                                                                                                        |
| gs\_total\_bet\_amount           | NUMERIC   | Total bet amount (real and bonus money)                                                                                                                               |
| gs\_avg\_bet\_amount             | NUMERIC   | Average bet amount                                                                                                                                                    |
| gs\_max\_bet\_amount             | NUMERIC   | Highest bet amount                                                                                                                                                    |
| gs\_wins\_count                  | NUMERIC   | Number of wins                                                                                                                                                        |
| gs\_total\_win\_amount           | NUMERIC   | Total win amount (real and bonus money)                                                                                                                               |
| gs\_avg\_win\_amount             | NUMERIC   | Average win amount                                                                                                                                                    |
| gs\_max\_win\_amount             | NUMERIC   | Highest win amount                                                                                                                                                    |
| gs\_total\_ggr                   | NUMERIC   | GGR of the session: total bet amount minus total win amount                                                                                                           |
| gs\_total\_ggr\_real             | NUMERIC   | GGR of the session in real money, without bonus money and with rollbacks taken into account. Empty when your platform does not send real and bonus amounts separately |
| gs\_bets\_rollback\_count        | NUMERIC   | Number of rolled-back bets                                                                                                                                            |
| gs\_wins\_rollback\_count        | NUMERIC   | Number of rolled-back wins                                                                                                                                            |
| gs\_total\_rollback\_bet\_amount | NUMERIC   | Total amount of rolled-back bets                                                                                                                                      |
| gs\_total\_rollback\_win\_amount | NUMERIC   | Total amount of rolled-back wins                                                                                                                                      |

Game sessions of the previous day: count, average length and total GGR in the label currency

```sql
SELECT COUNT(*) AS sessions,
       AVG(gs_session_length_seconds) AS avg_length_seconds,
       SUM(SAFE_DIVIDE(gs_total_ggr, user_to_label_cur_rate)) AS ggr_label_currency
FROM dwh_ext_xxx.tr_gs_game_session_ended
WHERE event_time >= TIMESTAMP_TRUNC(TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 DAY), DAY)
  AND event_time < TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), DAY)
```


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.smartico.ai/welcome/technical-guides/smartico-data-warehouse/smartico-dwh-transactional-views-system.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
