# Send PostHog conversion events to TikTok Ads - Docs

You should be aware that this destination relies on creating third-party cookies. You'll also need access to the relevant TikTok Ads account.

## Installation

1.  In PostHog, click the [Data pipeline](https://app.posthog.com/data-management/destinations) tab in the left sidebar.

2.  Click the [Destinations](https://app.posthog.com/data-management/destinations?search=tiktok) tab.

3.  Search for **TikTok Ads Conversions** and click **\+ Create**.

4.  Visit the [TikTok Events Manager](https://ads.tiktok.com/i18n/events_manager/home).

    1.  If you’ve already set up a Pixel for your website, we recommend that you use the same Pixel for your browser and server events.
        1.  To create a new Pixel, click **Connect data source** and select **Web**.
        2.  Skip the **Add your website** step.
        3.  For the connection method, select **Manual setup** and **Events API**.
        4.  Enter a name for your Pixel and click **Create**.
    2.  Go to your Pixel via **Data sources**.
    3.  Switch to the **Settings** tab and your Pixel ID will be listed as **ID**.
    4.  You can create an access token by clicking **Generate Access Token**.
5.  Back in PostHog, add the Pixel ID and Access token to the destination configuration.

6.  Set up your event and property filters to remove unnecessary events. You only want to send events that are conversions. Filter out unrelated events or ones missing required data.

7.  Press **Create & enable**, test your destination, and then watch your conversions get sent to TikTok Ads.

## Configuration

| Option | Description |
| --- | --- |
| Access tokenType: stringRequired: True | Check out this page on how to obtain such a token: [https://business-api.tiktok.com/portal/docs?id=1771101027431425](https://business-api.tiktok.com/portal/docs?id=1771101027431425) |
| Pixel IDType: stringRequired: True | You must obtain a Pixel ID to use the Conversions API. If you've already set up a Pixel for your website, we recommend that you use the same Pixel ID for your browser and server events. |
| User propertiesType: dictionaryRequired: True | A map that contains customer information data. See this page for options: [https://business-api.tiktok.com/portal/docs?id=1771101151059969#item-link-user%20parameters](https://business-api.tiktok.com/portal/docs?id=1771101151059969#item-link-user%20parameters) |
| Test Event CodeType: stringRequired: False | Use this field to specify that events should be test events rather than actual traffic. You'll want to remove your Test Event Code when sending real traffic through this integration. |

How to create this via the API

Using our REST API you can create this destination like so:

Terminal

PostHog AI

```bash
# Create a new destination
curl --location 'https://us.i.posthog.com/api/environments/:project_id/hog_functions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <POSTHOG_PERSONAL_API_KEY>' \
--data '{
    "type": "destination",
    "name": "TikTok Ads Conversions",
    "inputs": {
        "accessToken": {
            "value": ""
        },
        "pixelId": {
            "value": ""
        },
        "userProperties": {
            "value": {
                "ip": "{event.properties.$ip}",
                "city": "{not empty(person.properties.$geoip_city_name) ? replaceAll(lower(person.properties.$geoip_city_name), ' ', '') : null}",
                "email": "{not empty(person.properties.email) ? sha256Hex(lower(person.properties.email)) : ''}",
                "phone": "{not empty(person.properties.phone) ? sha256Hex(person.properties.phone) : ''}",
                "state": "{lower(person.properties.$geoip_subdivision_1_code)}",
                "ttclid": "{person.properties.ttclid ?? person.properties.$initial_ttclid}",
                "country": "{lower(person.properties.$geoip_country_code)}",
                "zip_code": "{not empty (person.properties.$geoip_postal_code) ? sha256Hex(replaceAll(lower(person.properties.$geoip_postal_code), ' ', '')) : null}",
                "last_name": "{not empty(person.properties.last_name) ? sha256Hex(lower(person.properties.last_name)) : ''}",
                "first_name": "{not empty(person.properties.first_name) ? sha256Hex(lower(person.properties.first_name)) : ''}",
                "user_agent": "{event.properties.$raw_user_agent}",
                "external_id": "{not empty(person.id) ? sha256Hex(person.id) : ''}"
            }
        }
    },
    "enabled": true,
    "template_id": "template-tiktok-ads"
}'
```

## FAQ

### Is the source code for this destination available?

PostHog is open-source and so are all the destination on the platform. The [source code](https://github.com/PostHog/posthog/blob/master/nodejs/src/cdp/templates/_destinations/tiktok_ads/tiktok.template.ts) is available on GitHub.

### Who maintains this?

This is maintained by PostHog. If you have issues with it not functioning as intended, please [let us know](https://us.posthog.com/#panel=support%3Asupport%3Aapps%3A%3Atrue)!

### What if I have feedback on this destination?

We love feature requests and feedback. Please [tell us what you think](https://us.posthog.com/#panel=support%3Afeedback%3Aapps%3Alow%3Atrue).

### What if my question isn't answered above?

We love answering questions. Ask us anything via [our community forum](/questions.md).

### Community questions

Ask a question

### Was this page useful?

HelpfulCould be better