# Integrate ByteBrew with Unity

> Integrate your User Acquisition campaigns with ByteBrew to pass engagement and post-install event data from your app.

Integrating with ByteBrew enables you to keep track of installs and receive post-install event postbacks for your ad campaigns. For the most up-to-date ByteBrew integration information, consult the [ByteBrew Developer Hub](https://docs.bytebrew.io/attribution-setup/attribution-unityads).

To activate the integration between Unity and ByteBrew, complete the following tasks:

1. Create a [Service account](#create-a-service-account) in the Unity User Acquisition dashboard.
2. Create [API keys](#create-api-keys) in your dashboard service account settings.
3. Complete the [integration workflow](#complete-the-bytebrew-integration-workflow) in the ByteBrew dashboard.

## Prerequisites

* [Add](/user-acquisition/getting-started/add-an-app.md) at least one app to the [Unity User Acquisition dashboard](https://cloud.unity.com/acquire).
* Initialize the ByteBrew SDK in your app. Refer to ByteBrew's [Unity SDK](https://docs.bytebrew.io/sdk/unity) integration guide for detailed initialization instructions.

## Create a Service account

A service account enables you to use the [Unity Advertising Statistics API](https://services.docs.unity.com/statistics/v2/index.html) with your ByteBrew integration. To create a Service account, do the following in the Unity User Acquisition dashboard:

1. From the left navigation menu, select **API Management**.
2. In the  Stats API v2.0 section, select **Service account**.
3. From the upper right corner of the **Service Accounts** page, select **+ New** to  open the **Create service account** dialog and create a new service account.
4. Enter the **Service account name** and **Service account description**. Refer to the following name and description examples:

* **Service account name**: ByteBrew attribution
* **Service account description**: ByteBrew attribution campaign metadata pull

5. Select **Create** to save your settings and  add the new service account to the list in the **Service Accounts** page.

## Create API keys

To enable programmatic data-sharing from the Unity Stats API in your ByteBrew integration, you need to create two API keys in your Service account settings: a **Key ID** and a **Secret Key**.

To create these keys, do the following in the **Organization** > **Service accounts** settings of the Unity Dashboard:

1. Find and select the service account you previously created. You can use the search bar to locate the account.
2. In the **Keys** section, select **+ Add key** to generate your keys and open the **New key has been created** dialog.
3. You need both the **Key ID** and **Secret key** from this dialog to complete your integration in the ByteBrew dashboard. Copy both keys.
4. Select **Done** to close the dialog.

## Complete the ByteBrew integration workflow

> **Important:**
>
> The following documentation discusses products or services (“Third-party Products”) not developed, owned, or operated by Unity.
> This information might be outdated or incomplete and is provided for your convenience.
> Your use of any Third-party Product is subject to its own terms.
> Unity makes no warranties regarding these products and isn't liable for any damages or losses arising from their use, including issues related to content, advertising, or materials from Third-party providers.

After creating a service account and API keys in the Unity Dashboard, go to the ByteBrew dashboard and do the following to complete your integration setup:

1. Select your app from the dashboard navigation menu.
2. Go to **Attribution** > **Network Settings** and find **UnityAds** from the list of networks.
3. Next to **UnityAds**, select **Setup** to open the **Add Ad Network** dialog.
4. Complete the **Network Settings** fields. Refer to the following tabs for instructions on where to locate these values in the User Acquisition dashboard:

1) **API Key**

   To retrieve your API Key from the User Acquisition dashboard, do the following:

   1. Go to the **API Management page**.
   2. Copy the **API Key** in the **Stats API v1.0** section.

2) **Game ID**

   To retrieve your [Game ID](../../getting-started/locate-advertiser-credentials#game-id) from the **Apps** page of the **User Acquisition** dashboard, follow these steps:

   1. From the dashboard left navigation menu, go to **Apps**. The provided table lists each of your organization's apps. Following each app name, the dashboard displays the app platform and Game ID.
   2. Select the **Copy** symbol next to the ID to copy it to your clipboard.

3) **Organization ID**

   To retrieve your Organization ID from the User Acquisition dashboard, follow these steps:

   1. Go to the **Settings** page.
   2. Copy the **Organization ID** from the **Organization** section of your settings.

4) **Organization Core ID**

   To retrieve your Organization core ID from the **Settings** page of the User Acquisition dashboard, follow these steps:

   1. Go to the **Organization** section of the **Settings** page.
   2. Copy the numeric ID next to **Organization core ID**.

5. Select **Next** to progress to the **Install Settings**\* tab of the dialog.
6. To enable view-through attribution, select the **Enable view through tracking**  checkbox and configure the view-through lookback window. ByteBrew generates Click-through attribution links by default.
7. Configure your attribution lookback windows in the following **Install Settings** fields:

| **Click-Through Window** | Yes | Use the **Days** selector to set the number of days an install can be attributed after a user clicks on your ad. | The maximum click-through lookback period is 30 days. The recommended best practice is to set the click-through setting to seven days or more for accurate attribution. |
| ------------------------ | --- | ---------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **View-Through Window**  | No  | Use the **Days** selector to set the number of days an install can be attributed after a user watches your ad.   | The maximum view-through lookback period is seven days. The recommended best practice is to set the view-through setting to one day or more for accurate attribution.   |

For more information about attribution lookback options, refer to the [Attribution lookback settings](/user-acquisition/partner-integration/bytebrew/data-sharing-reference.md#attribution-lookback-settings) section of the ByteBrew data-sharing reference.

8. In the **Send all install events from** section, choose whether to pass engagement data from all of your app's installs (including [unattributed](/user-acquisition/data-sharing/attribution/campaign-attribution-fundamentals.md) install data) or just those attributed to Unity. Choose from the following options:

* **Only this partner**
* **All Partners and Organics**
* **This Partner and Organics**

For more information about the install data source options, refer to the [Attribution data sources](/user-acquisition/partner-integration/bytebrew/data-sharing-reference.md#attribution-data-sources) section of the ByteBrew data-sharing reference.

9. Select **Next** to progress to the **Postback Settings** tab of the dialog.
10. To add a post-install event you want to pass to Unity, select **+ Add Postback Event** and choose from the following options:

* Ad Watched Event
* User App Open Event
* In-App Purchase Event

For more information about the postback event options, refer to the [Post-install event data-sharing section](/user-acquisition/partner-integration/bytebrew/data-sharing-reference.md) of the ByteBrew data-sharing reference.

> **Important:**
>
> Don’t define a new user event in your app code. ByteBrew tracks new user events by default using the **User App Open Event** option. For more information, refer to the [ByteBrew Developer Hub](https://docs.bytebrew.io/attribution-setup/attribution-unityads) Attribution documentation.

11. In the **Postback Events Settings** section, choose whether to pass post-install event data from all  your app's installs (including [unattributed](/user-acquisition/data-sharing/attribution/campaign-attribution-fundamentals.md) install data) or just those attributed to Unity. Choose from the following options:

* Send only from this partner
* Send from all Networks and Organics
* Send only from this Partner and Organics

For more information about the post-install event data source options, refer to the [Postback data sources](/user-acquisition/partner-integration/bytebrew/data-sharing-reference.md#postback-data-sources) section of the ByteBrew data-sharing reference.

12. On the final tab of the network setup dialog, you can copy your attribution links. For instructions on how to integrate these URLs in the User Acquisition dashboard, refer to [Integrate attribution links with Unity](/user-acquisition/data-sharing/attribution/integrate-attribution-links.md).
13. Select **Finish** to complete the integration.
