# Required event data for Airflux integration

This section outlines the event data that must be collected and sent using the Airflux SDK to ensure proper AI model training and achieve optimal results.&#x20;

## Required event data per revenue model

Depending on the revenue model of your game, different event data is required for utilizing Airflux. Refer to the table below.&#x20;

<table><thead><tr><th width="250.82421875">Revenue Model	</th><th>Required Events </th><th data-hidden></th></tr></thead><tbody><tr><td>In-app advertising only</td><td><code>AD_IMPRESSION</code>, <code>ACHIEVE_LEVEL</code>, <code>SPEND_CREDITS</code></td><td></td></tr><tr><td>In-app purchase only</td><td><code>ACHIEVE_LEVEL</code>, <code>ORDER_COMPLETED</code>, <code>SPEND_CREDITS</code></td><td></td></tr><tr><td>In-app advertising + In-app purchase </td><td><code>AD_IMPRESSION</code>, <code>ACHIEVE_LEVEL</code>, <code>ORDER_COMPLETED</code>, <code>SPEND_CREDITS</code></td><td></td></tr></tbody></table>

Note that the Install and Open events are automatically collected by the Airbridge SDK upon installation and no additional setup is needed.&#x20;

## Detailed schema per event

Find the key attributes and code examples for collecting the required event data below. &#x20;

<details>

<summary>Ad Impression (IAA-related event)</summary>

{% hint style="danger" %}
**Attention**

The in-app ad revenue data must be collected using the client-side SDK through mediation platform integrations and sent to Airflux.&#x20;
{% endhint %}

Track ad impressions when ad is shown to the player and collect relevant data, such as ad type, ad revenue, placement, and more.

For example, when ad revenue is generated after an interstitial ad is shown, call the `TrackEvent()` function, set the event category to `AirfluxCategory.AD_IMPRESSION`, and add `"adType"` to `customAttributes` to send `interstitial` as a value.

<table><thead><tr><th width="169.89453125">Attribute Type</th><th width="134.97265625">Name</th><th width="127.4609375">Semantic Attributes Description</th><th>Sample Value</th></tr></thead><tbody><tr><td>Semantic Attribute</td><td>Currency</td><td>Currency for ad revenue</td><td>USD</td></tr><tr><td>Semantic Attribute</td><td>Value</td><td>Ad revenue amount</td><td>1.99</td></tr><tr><td>Custom Attribute</td><td>adType</td><td>The type of the ad</td><td>reward: Rewarded ad<br>interstitial: Interstitial ad<br>banner: Banner ad</td></tr><tr><td>Custom Attribute</td><td>ad_placement</td><td>Ad placement</td><td>rw_offline: Offline reward ad<br>rw_get_item: Rewarded ad for obtaining items like weapons, skins, etc.<br>rw_get_coin: Rewarded ad for earning coins<br>rw_get_gem: Rewarded ad for earning gems<br>rw_time_skip: Rewarded ad for reducing recovery time<br>int_next_stage: Interstitial ad that is presented when advancing to the next stage<br>bn_next_stage: Banner ad that is presented when advancing to the next stage</td></tr><tr><td>Custom Attribute</td><td>stage_type</td><td>The type of the stage</td><td>main: Main stage<br>promotion: Seasonal promotion stage (updated every 3 months)</td></tr><tr><td>Custom Attribute</td><td>stage_number</td><td>The stage number where interstitial or rewarded ads are presented after Success, Fail, Give-up, or Retry. Otherwise, null is collected.</td><td>main: 1, 2, ..., 550 (30 new stages added every months)<br>promotion: 1, 2, ...,100</td></tr><tr><td>Custom Attribute</td><td>reward_item</td><td>The reward earned by the player after engaging with a rewarded ad. For other ad types, null is collected.</td><td>coin: Number of coins earned<br>gem: Number of gems earned</td></tr></tbody></table>

#### Code example

```csharp
// Example: Ad revenue transmission from AdMob
Airflux.TrackEvent(
    category: AirfluxCategory.AD_IMPRESSION,
    semanticAttributes: new Dictionary<string, object>()
    {
        { AirfluxAttribute.VALUE, 0.01 }, // Required: Ad revenue
        { AirfluxAttribute.CURRENCY, "USD" }, // Required: Currency code
        {
            AirfluxAttribute.AD_PARTNERS, new Dictionary<string, object>()
            {
                {
                    "mopub", new Dictionary<string, object>()
                    {
                        { "app_version", "5.18.0" },
                        { "adunit_id", "12345" },
                        { "adunit_name", "12345" },
                        { "adunit_format", "Banner" },
                        { "id", "12345" },
                        { "currency", "USD" },
                        { "publisher_revenue", 12345.123 },
                        { "adgroup_id", "12345" },
                        { "adgroup_name", "12345" },
                        { "adgroup_type", "12345" },
                        { "adgroup_priority", "12345" },
                        { "country", "kr" },
                        { "precision", "publisher_defined" },
                        { "network_name", "12345" },
                        { "network_placement_id", "12345" },
                        { "demand_partner_data", "12345" },
                    }
                }
            }
        },
    },
    customAttributes: new Dictionary<string, object>()
    {
        { "adType", "reward" }, // Ad type (e.g., rewarded, interstitial)
        { "ad_placement", "main_banner" }, // Ad placement (Detailed explanation of the ad_context value required after SDK installation is complete)
        { "stage_type", "Main" }, // Main or promotional stage (e.g., Main, Event)
        { "stage_number", "1" }, // The stage number where interstitial or rewarded ads are shown after Success, Fail, Give-up, or Retry. Otherwise, null is collected. 
        { "reward_item", new Dictionary<string, object> {{"coin", 10}, {"gem", 20}} } // The reward earned by the player after engaging with a rewarded ad. For other ad types, null is collected.
    }
);

```

</details>

<details>

<summary>Order Completed (IAP-related event)</summary>

{% hint style="danger" %}
**Attention**

The in-app purchase revenue data must be collected using the client-side SDK and sent to Airflux. There might be a slight gap between the data sent to Airflux and the revenue data provided by vendors.
{% endhint %}

Track in-app purchases and relevant data such as item information, transaction ID, the purchased amount, the payment currency, and more. &#x20;

For example, when a dialog is prompted confirming a purchase of an item, call the `TrackEvent()` function, set the event category to `AirfluxCategory.ORDER_COMPLETED`, and add `AirfluxAttribute.PRODUCT_ID` and `AirfluxAttribute.PRODUCT_NAME` to send information of the purchase item.&#x20;

{% hint style="warning" %}
The payment currency information (`AirfluxAttribute.CURRENCY` )and the purchase amount  (`AirfluxAttribute.VALUE)` must be included in the event data for accurate revenue analysis.&#x20;
{% endhint %}

<table><thead><tr><th width="169.89453125">Attribute Type</th><th width="115.31640625">Name</th><th width="127.4609375">Semantic Attributes Description</th><th>Sample Value</th></tr></thead><tbody><tr><td>Semantic Attribute</td><td>Transaction ID</td><td>Transaction ID</td><td>TXN-20250411-5F3C9A72B1</td></tr><tr><td>Semantic Attribute</td><td>Currency</td><td>Currency for ad revenue</td><td>USD</td></tr><tr><td>Semantic Attribute</td><td>Value</td><td>Ad revenue amount</td><td>10.99</td></tr><tr><td>Semantic Attribute</td><td>Product ID</td><td>Product ID</td><td>1C569KY32P1</td></tr><tr><td>Semantic Attribute</td><td>Product Name</td><td>Product Name</td><td>remove_ads: ""Ad Removal"" as a purchase item<br>welcome_pack: Item package for newly acquired players<br>starter_pack: Item package for beginners<br>coin_pack_1: Coin package<br>gem_pack_2: Gem package<br>limited_skin_1: Time-limited skin</td></tr><tr><td>Custom Attribute</td><td>purchase_route</td><td>The source of the purchase</td><td>shop: Purchased from the shop<br>popup: Purchased from a pop-up</td></tr></tbody></table>

#### Code example

```csharp
Airflux.TrackEvent(
    // StandardCategory
    category: AirfluxCategory.ORDER_COMPLETED, // or "CustomEvent" (CustomCategory)
    // SemanticAttributes
    semanticAttributes: new Dictionary<string, object>()
    {
        { AirfluxAttribute.VALUE, 11 }, // Required: Actual purchase amount
        { AirfluxAttribute.TRANSACTION_ID, "8065ef16-162b-4a82-b683-e51aefdda7d5" }, // Required: Transaction ID
        { AirfluxAttribute.CURRENCY, "USD" }, // Required: Currency code 
        {
            AirfluxAttribute.PRODUCTS, new List<object>()
            {
                new Dictionary<string, object>()
                {
                    { AirfluxAttribute.PRODUCT_ID, "1C569KY32P1" }, // Required, Product ID
                    { AirfluxAttribute.PRODUCT_NAME, "remove_ads" } // Required, Product name (welcome_back, remove_ads, starter_pack ...)
                } 
            }
        }
    },
    // CustomAttributes
    customAttributes: new Dictionary<string, object>()
    {
        { "purchase_route", "shop" } // (Optional) shop / popup
    }
```

</details>

<details>

<summary>Achieve Level</summary>

Track player game progress and how a stage ended.&#x20;

For example, when a stage ends, call the `TrackEvent()` function, set the event category to `AirfluxCategory.ACHIEVE_LEVEL`, and add `"stage_type"` and `"stage_number"` to track the stage type and stage number.

Additionally, use `"result"` to send information on how the stage ended, such as `success`, `fail`, `giveup`, and `retry` .

<table><thead><tr><th width="169.89453125">Attribute Type</th><th width="115.31640625">Name</th><th width="127.4609375">Semantic Attributes Description</th><th>Sample Value</th></tr></thead><tbody><tr><td>Custom Attribute</td><td>stage_type</td><td>The type of the stage</td><td>main: Main stage<br>promotion: Seasonal promotion stage (updated every 3 months)</td></tr><tr><td>Custom Attribute</td><td>stage_number</td><td>The stage number where Success, Fail, Give-up, or Retry occurred.</td><td>main: 1, 2, ..., 550 (30 new stages added every months)<br>promotion: 1, 2, ...,100 </td></tr><tr><td>Custom Attribute</td><td>result</td><td>The result of the stage</td><td>success: Stage completed successfully<br>fail: Stage failed<br>giveup: Stage abandoned<br>retry: Stage retried after failure or exit</td></tr></tbody></table>

#### Code example

```csharp
Airflux.TrackEvent(
    // StandardCategory
    category: AirfluxCategory.ACHIEVE_LEVEL, // or "CustomEvent" (CustomCategory)
    // SemanticAttributes
    semanticAttributes: new Dictionary<string, object>(),
    // CustomAttributes
    customAttributes: new Dictionary<string, object>()
    {
        { "stage_type", "main"},
        { "stage_number", 13  },
        { "result", "success" }      
    }
);
```

</details>

<details>

<summary>Spend Credits</summary>

Track in-game currency spending and relevant data, such as in-game currency information, spending amount, and more.

For example, when the player spends in-game currency, such as coins and gems, call the `TrackEvent()` function, set the event category to `AirfluxCategory.SPEND_CREDITS` and add `"item_type"` and `"item_amount"` to send the in-game currency type and spending amount.

Additionally, use `"stage_type"` and `"stage_number"`to to track the stage type and stage number.

<table><thead><tr><th width="169.89453125">Attribute Type</th><th width="115.31640625">Name</th><th width="253.59765625">Semantic Attributes Description</th><th>Sample Value</th></tr></thead><tbody><tr><td>Custom Attribute</td><td>item_type</td><td>The type of the in-game currency spent</td><td>coin<br>gem</td></tr><tr><td>Custom Attribute</td><td>item_amount</td><td>The amount of the in-game currency spent</td><td>10, 20</td></tr><tr><td>Custom Attribute</td><td>stage_type</td><td>The type of the stage</td><td>main: Main stage<br>promotion: Seasonal promotion stage (updated every 3 months)</td></tr><tr><td>Custom Attribute</td><td>stage_number</td><td>The current stage of the player</td><td>main: 1, 2, ~ , 550 (30 new stages added every months)<br>promotion: 1, 2, ~ ,100</td></tr></tbody></table>

#### Code example

```csharp
Airflux.TrackEvent(
    // StandardCategory
    category: AirfluxCategory.SPEND_CREDITS, // or "CustomEvent" (CustomCategory)
    // SemanticAttributes
    semanticAttributes: new Dictionary<string, object>(),
    // CustomAttributes
    customAttributes: new Dictionary<string, object>()
    {
        { "item_type", "coin" },
        { "item_amount", 100  },
        { "stage_type", "main"},
        { "stage_number", 13 }
    }
);
```

</details>


---

# Agent Instructions: 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.airflux.ai/airflux-reference/required-event-data-for-airflux-integration.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.
