> ## Documentation Index
> Fetch the complete documentation index at: https://docs.appstack.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# TikTok

With the TikTok Ads integration, you can:

1. Run enhanced app campaigns.
2. Import all your ad campaigns (app and web).
3. Enable Appstack to audit TikTok's reporting capabilities.
4. Allow Appstack to send in-app events, postbacks (signals) back to TikTok Ads.

<Note>
  **To successfully connect TikTok Ads, you must:**

  1. Have 'Administrator' access over the right TikTok Ads business center or ad account. 'Standard' access is not enough to make the integration work.
  2. Ensure the app used in Appstack is connected to the correct ad account.
</Note>

<AccordionGroup>
  <Accordion title="Available metrics and definitions">
    | Metrics                   | Definition                                                                |
    | :------------------------ | :------------------------------------------------------------------------ |
    | Ad spend                  | Money paid to run ads                                                     |
    | Installs                  | New or old users who installed the app                                    |
    | Cost per install (CPI)    | Cost per install from your ad campaigns. Formula: Ad spend / Installs     |
    | Installs per mille (IPM)  | Installs per 1,000 impressions. Formula: (Installs / Impressions) x 1,000 |
    | Impressions               | Number of times an ad was shown                                           |
    | Cost per mille (CPM)      | Cost per 1,000 impressions. Formula: (Ad spend / Impressions) x 1,000     |
    | Clicks                    | Number of times an ad was clicked                                         |
    | Cost per click (CPC)      | Cost per click. Formula Ad spend / Clicks                                 |
    | Click-through rate (CTR)  | How often an impression becomes a click. Formula: Clicks / Impressions    |
    | Click to install rate     | Share of clicks that became installs. Formula: Installs / Clicks          |
    | Return on ad spend (ROAS) | Return on ad spend. Formula: Ads revenue / Ad spend                       |
    | Revenue                   | Total money earned from attributed users.                                 |
  </Accordion>

  <Accordion title="Available in-app events and definitions">
    | In-app events         | Definition                                                          |
    | :-------------------- | :------------------------------------------------------------------ |
    | Achieve level         | User reaches a level/milestone                                      |
    | Add payment info      | User enters or saves payment details                                |
    | Add to cart           | User adds an item to the shopping cart                              |
    | Complete registration | User finishes sign-up (account creation)                            |
    | Initiate checkout     | User starts the checkout flow                                       |
    | Session               | App open, resulting in a user session                               |
    | View content          | User views a key screen/content item                                |
    | Start trial           | User begins a free trial for a subscription                         |
    | Subscription          | First paid subscription period begins (with or without prior trial) |
    | Purchase              | One-time in-app purchase (consumable or non-consumable)             |
  </Accordion>
</AccordionGroup>

## Connect to TikTok Ads

The first step is to connect your TikTok Ads account with Appstack. Follow these steps:

1. In Appstack, from the side menu, select **Integrations** > **TikTok Ads.**
2. Click on **Connect to TikTok Ads.**
3. In TikTok's access integration flow, log in to your TikTok Business account with access to the correct ad account and apps.
4. **Accept** the requested permissions by clicking Confirm, and you will then be redirected to Appstack's integration page.

## Configure the Events API

Configuring the Events API with Appstack will allow you to run enhanced app campaigns using the assigned ads link.

<Steps>
  <Step title="Configure the pixel ID and events API access token">
    The pixel ID is the destination that receives all Events API events, not only Appstack-attributed ones. Choosing the wrong pixel ID will cause your app's events to be sent to the wrong destination.

    <Accordion title="How to create a new pixel ID">
      <Note>
        **Information**

        For additional information on how to create the pixel ID and get the Events API access token: [Official documentation](https://ads.tiktok.com/help/article/how-to-create-and-access-tiktok-pixel-id?lang=en)
      </Note>

      Follow these steps if you don't have an existing pixel:

      1. At the Business Center level, go to 'Assets' and click **Add a pixel.**
      2. Select 'New pixel' and click on **Next.**
      3. Add your website URL, then click **Next.**
      4. Select 'Manual setup' and click on **Next.**
      5. Select 'Events API' only and click on **Next.**
      6. Add a name to your pixel, then click **Create.**
      7. In the 'Set up your business funnel' section, select E-commerce as the template, then click **Next.**
      8. **Copy** the pixel ID (example of a pixel ID: D6DSQIJJ77U7GSLDGAY0).
      9. **Generate an access token** and copy it (e.g., 2b5700268ay04e741f0045w5f5c17f442ad713fb).
      10. Click on **Finish.**
      11. Go back to the Business Center page, go to **Assets**, and click on the newly created pixel.
      12. Click on **Link accounts**, select the correct ad account, then click on **Confirm.**
    </Accordion>

    To find an existing pixel ID, follow these steps:

    1. At the Business Center level, go to **Assets** and ensure that the pixel is connected to the correct ad account.
    2. Click on **Open in Events Manager** to see the pixel ID and generate the access token.
    3. Copy the pixel ID located at the top left under the pixel name.
    4. On the same page, click on **Settings.**
    5. Scroll down to the 'Events API' section and click on **Generate access token.**
    6. **Copy** the access token.

    <Tip>
      It's recommended to use a new data source (pixel ID) to work with clean data
    </Tip>
  </Step>

  <Step title="Sending events">
    To successfully send in-app events to TikTok Ads:

    1. Select the in-app events from the dropdown button under the **Appstack SDK events** column.
    2. Map the selected in-app event to a TikTok standard event. For example, if you want to optimize your ad campaigns towards the SDK event **START\_TRIAL**, you can select the TikTok standard event called **StartTrial**.

    <Note>
      **Information**

      1. To complete this step successfully, you first need to receive an install event from the Appstack SDK.
      2. Once the in-app events are selected, they will take between 30 and 90 minutes to appear in your dataset in the TikTok Events Manager.
      3. Appstack sends all events to TikTok Events Manager, not only the attributed ones. 
      4. TikTok does not support custom events for campaign optimization. Learn more on the official site: [TikTok events documentation](https://business-api.tiktok.com/portal/docs?id=1771101186666498).
      5. Some standard events, such as 'StartTrial', cannot be used for campaign optimization when the campaign objective is 'Sales'. Only works with the 'Lead generation' objective.
    </Note>
  </Step>

  <Step stepNumber={3} title="Create your first enhanced app campaign">
    1. **Copy the ad link** from the Appstack's integration page (located at the bottom of the page).
    2. Inside TikTok Ads Manager, click on **+ Create** to start the campaign creation flow.
    3. Select **Sales** (recommended if optimizing for Purchase or Subscribe) or **Lead generation** (recommended if optimizing for Signup or Start Trial) as the campaign objective. Then select **Website** as 'Sales destination' (don't select App) and choose between **Manual** or **Search** as the 'campaign type'.
    4. At the ad set level, under the 'Optimization location' section, select **Website** as the 'Location', select the **correct dataset** (same as in Appstack), and for the 'Optimization event' select the **in-app event** you want the campaign to optimize for.
    5. In the **Placements** section, at the device level, ensure that only TikTok is selected (avoid automatic placement).
    6. In the **Targeting** section, ensure only one operating system is selected (iOS or Android).
    7. In the **Bidding** section, you can select **Conversion** or **Value** as the 'Optimization goal.' 
    8. At the ad level, **paste the ad link** into the ‘Website URL’ box. Don’t paste the URL parameters in the ‘Tracking’ section, copied in the first step.

    <Note>
      **Information**

      1. Not selecting the specific operating system (device) at the ad set level will affect your ad performance, as users will click the ad links but not be able to download the app because the ad links are specific to each operating system (iOS or Android).
      2. To enable value-based optimization (VBO), you need to have obtained at least 20 attributed, unique, complete payment events with value and currency over any consecutive 7-day period on TikTok. Learn more on the official site: [How to enable value-based optimization.](https://ads.tiktok.com/help/article/how-to-promote-a-website-using-value-based-optimization)
      3. The Sales campaign objective doesn't support optimizing for 'Start trials', so you need to select 'Lead generation' as the campaign objective. At the ad set level, you can configure the 'Purchase' or 'Subscribe' in-app events as 'Deep funnel optimization' to improve the performance. Learn more about 'Deep funnel optimization' on the official site: [About deep funnel optimization](https://ads.tiktok.com/help/article/about-deep-funnel-optimization).
    </Note>
  </Step>
</Steps>

## Troubleshooting

### **General tips**

1. Check your permissions: Ensure you have admin access to connect.
2. Verify app connections: Ensure your app is correctly connected to the ad accounts.
3. Update tokens: Generate fresh API keys and access tokens by reconnecting.
4. Missing metrics in TikTok: Ensure you select the web-based metric in TikTok Ads Manager to view total downloads and in-app events.
5. Contact support: If issues persist, reach out to our support team with specific error messages at [support@appstack.tech](mailto:support@appstack.tech).

### Error messages

| Error                 | How to fix                                                                                                                                                                                       |
| :-------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Authentication failed | 1. Go to your TikTok Business Center<br />2. Check that your user account has the correct permissions<br />3. Try to connect again in Appstack                                                   |
| Application not found | 1. Verify your app ID is correct in TikTok Business Center<br />2. Ensure your user account has access to the correct ad account<br />3. Check that the app is connected to the right ad account |
