> ## 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.

# Meta

With the Meta Ads integration, you can:

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

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

  1. Have Full/Admin control access to the right ad business portfolio (including Business Manager and Meta for Developers). Partial access is not enough to make the integration work.
  2. Ensure the app used in Appstack (it must be created in Meta for Developers) 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 Meta Ads

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

1. In Appstack, from the side menu, select **Integrations** > **Meta Ads**
2. Click on **Connect to Meta Ads**
3. In Meta’s access integration flow, select the correct business portfolio that contains the proper ad accounts and apps
4. Ensure that you click on **Select all** ad accounts
5. Accept the requested permissions and click on **Save**
6. Click on **Got it** and then you will get redirected to Appstack’s integration page

## Configure the Conversion API

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

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

    <Note>
      **Information**

      1. [Click here](https://www.facebook.com/business/help/5818684664831465?id=490360542427371) to learn how to create a new dataset in Meta Events Manager
      2. For additional information on how to get the Conversion API access token, follow the official instructions: [Get access token](https://developers.facebook.com/docs/marketing-api/conversions-api/get-started/#access-token)
    </Note>

    1. Once the connection shows as **Active**, select the correct dataset ID from the dropdown in Appstack.
    2. To generate the Conversion API access token, follow these steps:
       * Go to your Meta Events Manager.
       * Select the correct dataset from the drop-down.
       * Click on **Settings** in the right sidebar.
       * Scroll down to the **Conversions API** section.
       * Click **Generate Access Token.**
       * **Copy** the generated token.
       * **Paste** the access token in the Conversion API access token field.
    3. Click on **Save** to confirm the dataset ID and access token, enabling the integration.
  </Step>

  <Step title="Sending events">
    To successfully send in-app events to Meta Ads, select the in-app events from the dropdown button under the 'Appstack SDK events' column.

    Appstack will automatically generate a new custom event called 'appstack\_\[eventName]'. It will be sent to Meta Ads (to the selected dataset), and this event will be used as the optimization goal when setting up the ad campaign.

    <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 Meta Events Manager.
      3. Appstack sends all events to Meta Events Manager, not only the attributed ones. 
      4. All events sent by Appstack are set as custom events, not standard; therefore, they won't affect your current setup.
    </Note>
  </Step>

  <Step title="Accept the custom events and verify the Appstack domain">
    Follow these instructions to accept the custom events in Meta Events Manager:

    1. After you select the in-app events you want to send to Meta Ads, go to 'Meta Events Manager,' and inside the proper dataset, you will see a warning that says: 'Confirm custom event(s) that belong to you and click on **Review events.**
    2. Click on **I acknowledge** to continue.
    3. Select all the in-app events that start with the name 'appstack\_' and click on **Next.**
    4. Select the **Confirm the custom event** option, then click **Confirm.**
    5. Now it's time to verify the Appstack domain. Inside the same dataset, go to **Settings** and scroll down to the **Traffic Permissions - Websites** section.
    6. Click on **Create an allow list.**
    7. Look for the domain [appstack.tech](http://appstack.tech) and click **Add to allow list.**
    8. Click on **Confirm.**

    <Note>
      You must wait for the in-app events to arrive before doing this step.
    </Note>
  </Step>

  <Step 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 Meta Ads Manager, click on **+ Create** to start the campaign creation flow.
    3. Select **Sales** (recommended) as the campaign objective.
    4. At the ad set level, under the 'Conversion' section, select **Website** only as the 'Conversion location', select the **correct dataset** (same as in Appstack), and for the 'Conversion event' select the event you want the campaign to optimize for.
    5. At the ad set level, under the 'Placements' section, click on 'Show more settings' and select only **Mobile** and the **correct operating system** depending on the advertised app. Also, you must disable 'Audience Network' as a platform.
    6. At the ad level, **paste the ad link** into the 'Website URL' box. Don't paste the URL parameters in the 'Tracking' section; copy them from the first step.

    <Note>
      **Information**

      1. App installs (appstack\_install) are available as a metric in Ads Manager only if they were selected as an optimization goal. You can still see them inside the Appstack dashboard.
      2. To unlock the appstack\_installs metric, you need to launch a campaign that optimizes for this event. Once you do it, you will be able to unlock this metric for all future campaigns.
      3. Remember to always select mobile-only and the correct operating system in the 'Placements' section at the ad set level.
    </Note>
  </Step>
</Steps>

## Troubleshooting

### **General tips**

1. Check your permissions: Ensure you have the required access levels for each platform.
2. Verify app connections: Ensure your app is correctly connected to the ad accounts.
3. Missing dataset: Click on **Refresh datasets** below the dataset dropdown to update the token.
4. Update tokens: Generate fresh API keys and access tokens by reconnecting.
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 Meta Business Manager<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 Meta Business Manager<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 |
