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

# X (Twitter) Ads as a Traffic Source

> Track X (Twitter) Ads clicks in ClickFlare: capture the twclid click ID, pass campaign names, and report conversions with the X Pixel or Conversion API.

![X (Twitter) traffic source template](https://mintcdn.com/clickflare/oNlhH4HxR5JFsOiP/images/integrations/covers/templates/x-twitter.png?fit=max\&auto=format\&n=oNlhH4HxR5JFsOiP\&q=85\&s=f7d57297201e5aadc8db778d81e5fe83)

X (formerly Twitter) sells promoted posts, video ads and website cards that appear in the timeline, in search and on profiles. This guide sets up X as a traffic source in ClickFlare. It covers what the built-in template does, how to capture X's click ID and campaign details, and how conversions get back to X.

You do everything from the **campaign editor**. The X traffic source is created inline, without leaving the campaign.

The template is minimal. It tracks clicks, not conversions. X has no postback URL and no dynamic URL macros, so most of the work happens on the X side.

## At a glance

| | |
| - | - |
| **Ad formats** | Promoted posts, video ads, website cards |
| **Click ID** | `twclid`, added to your URL by X on ad clicks. The template reads it. |
| **URL macros** | None. X doesn't replace dynamic macros in destination URLs. |
| **Conversion tracking** | No S2S postback. X Pixel on your conversion page, or X's Conversion API on your side. |
| **Payout passed back** | Only through the X Pixel or X's Conversion API |
| **Cost** | Not passed. Set a cost model on the campaign. |
| **Conversion API** | Not in ClickFlare. X's Conversion API must be called from your own server. |

## What the template contains

The template has a single parameter row and nothing else:

| Name | TS Parameter | TS Token (X macro) | ClickFlare Token | What it carries |
| - | - | - | - | - |
| external\_id | `twclid` | *empty* | `{external_id}` | X's click ID. X appends it to ad clicks itself, so there is no macro. |

![The X template's Parameters table in ClickFlare, with twclid set as the External ID parameter](https://mintcdn.com/clickflare/nZP6EuFBEVoKPMxM/images/integrations/templates/x-twitter/parameters.png?fit=max\&auto=format\&n=nZP6EuFBEVoKPMxM\&q=85\&s=d6f827d13eb5c6c852a3416b5872aef4)

There is no postback URL, no pixel URL and no cost row. ClickFlare captures X's click ID and records the visit, the country, the device, the browser and everything else it detects itself. It has no other X-specific data.

## How it works

**1. X sends the click**

A visitor clicks your ad. X opens your ClickFlare campaign URL and appends its click ID in the `twclid` parameter.

**2. ClickFlare stores the X click ID**

With `twclid` set as the parameter of the `external_id` row, ClickFlare saves its value as the visit's **External ID**. It then sends the visitor to your lander or offer.

**3. The conversion reaches ClickFlare**

Your affiliate network or store posts the conversion back to ClickFlare, matched on the ClickFlare click ID.

**4. The conversion reaches X**

ClickFlare can't post it to X. The X Pixel on your conversion page reports it from the visitor's browser, or your own server sends it to X's Conversion API with the `twclid`.

> [!NOTE]
>
> The mirror, as far as X allows: in the **campaign URL** you normally write *ClickFlare's* parameter and *the network's* macro. X has no macros, so there is nothing to mirror. The click ID works like Pinterest's: X appends `twclid=...` itself, and the template's `external_id` row tells ClickFlare to read the `twclid` parameter. There is no postback URL, so the second half of the mirror (X's parameter plus ClickFlare's token) doesn't exist.

## Before you start

* **Set up your own tracking domain.** Run the campaign on your own custom domain. Shared domains get flagged by ad platforms and blocked by browsers. See [Custom Domains](/docs/en/settings/custom-domains.md).
* **Have an offer ready in ClickFlare**, and its affiliate network set up to post conversions back to ClickFlare. See [Creating an Offer](/docs/en/tracking/creating-an-offer-1.md) and [Adding an Affiliate Network](/docs/en/tracking/adding-an-affiliate-network.md).
* **Set up the X Pixel on your site**, if you want X to see conversions. You need to be able to add code to the page the visitor sees after converting. If you send traffic to an affiliate offer you don't own, X can only learn about conversions through X's Conversion API.
* **Know that X has no URL macros.** Campaign, ad group and ad names can't be filled in automatically. Plan one campaign URL per ad group if you want that split in ClickFlare.

***

## Step 1 – Create the campaign and the X traffic source

1. Go to **Campaigns** and click **New**.
2. In **Traffic Source**, open the dropdown and click **+ New Traffic Source**.
3. Search for `X` or `twitter` and select the X template.
4. Enter a **Name**, for example `X Ads`.
5. Set **Cost currency** to your X ad account's currency.
6. Leave the `external_id` row as it is: `twclid` as the **TS Parameter** and an empty **TS Token**. X adds the value itself.

> [!WARNING]
>
> Don't type a macro into the TS Token of the `external_id` row. X has none, and the literal text would be sent instead. Without `twclid` in that row, ClickFlare doesn't capture X's click ID, and you lose the one value that ties a ClickFlare visit to an X click.

### Passing campaign and ad details

X doesn't replace dynamic macros in destination URLs. To split reports by X campaign or ad group, pass the names as fixed values:

1. Click **Add Parameter**. Name it `campaign`, set the **TS Parameter** to `campaign` and the **TS Token** to a placeholder such as `CAMPAIGN_NAME`.
2. Repeat for `adgroup` with `ADGROUP_NAME`, and for `ad` with `AD_NAME` if you want ad-level splits.
3. ClickFlare assigns the next free tracking field to each one.

When you copy the campaign URL in Step 3, replace each placeholder with the real name before you paste the URL into X. Use short names without spaces, for example `campaign=spring_us&adgroup=lookalike_1`. Every ad group gets its own copy of the URL with its own values.

This is manual work, and it's the only way to get X's structure into ClickFlare. If you don't need the split, skip it. You can still compare ClickFlare campaigns, landers and offers.

## Step 2 – Send conversions to X

X doesn't accept S2S postback URLs. Leave **Traffic source postback URL** off on this traffic source. There are two ways to get conversions to X, both on the advertiser side.

### Option A: The X Pixel on your conversion page

The X Pixel is X's JavaScript tag. Its base code goes on every page of your site. An event code fires on the page where the conversion happens, for example the thank-you page.

1. In X Ads Manager, open **Events Manager** and set up the X Pixel as an event source.
2. Create a conversion event for the action you want to track, for example Purchase or Lead. X gives each event its own ID.
3. Install the base code on your site and the event code on the conversion page.
4. Pass the conversion value in the event code if you want X to report revenue.

The pixel only counts when it runs in the visitor's browser. ClickFlare can't fire it for you as a server-side postback.

### Option B: X's Conversion API, from your server

X's Conversion API receives conversions server-to-server. ClickFlare doesn't have an X Conversion API integration, so this has to be built on your side, or by a tool that supports it. What X needs:

* **At least one identifier.** X recommends always sending the click ID (`twclid`). Email and phone also work. IP address and user agent only count alongside a second identifier.
* **The conversion event** you created in Events Manager. To deduplicate against the X Pixel, use the same event the pixel uses and send the same conversion ID from both.
* **Ads API access**, which X grants through your X representative.

The `twclid` you need is the External ID ClickFlare stored in Step 1. Your server can read it from the conversion data or pass it on from the lander.

## Step 3 – Finish the campaign and copy its URL

1. Name the campaign.
2. Set the **Cost Model**. See [Cost](#cost).
3. Choose **Redirect** or **Direct** tracking. See the note below.
4. Click **Next** and, on **Destination**, add your lander (optional) and your offer.
5. Save, open **Tracking**, select your own tracking domain and copy the **campaign URL**.

The campaign URL has no X parameters unless you added them in Step 1. It doesn't contain `twclid`. X adds that on the click.

**Redirect or Direct?** With **Redirect**, X's click (and its `twclid`) lands on your ClickFlare domain. ClickFlare captures it. An X Pixel on your lander won't see `twclid`, though, because the visitor arrives at the lander without it. If you rely on the X Pixel, use **Direct** tracking, so X sends the visitor straight to your lander with `twclid` in the URL. See [Direct Campaign Tracking](/docs/en/campaigns/direct-campaign-tracking.md).

If you use a lander, its call-to-action must link to the ClickFlare **click URL**, not to the offer directly. Otherwise the visit reaches the offer without a ClickFlare click ID, and the conversion can't be traced back to X.

See [Creating a Campaign in ClickFlare](/docs/en/campaigns/creating-a-campaign-in-click-flare.md).

## Step 4 – Create the ad in X

1. In X Ads Manager, create a campaign and an ad group with your objective, targeting and budget.
2. When you create the ad, paste the ClickFlare campaign URL as the ad's destination URL (website URL).
3. If you added `campaign` and `adgroup` parameters, make sure each ad group uses the URL with its own values.
4. Launch the campaign.

## Step 5 – Test the integration

1. Click your live ad, or wait for the first clicks.
2. In ClickFlare, open the campaign report and group by **External ID**. Values should be X click IDs. If the column is empty, check the `twclid` parameter on the `external_id` row.
3. If you added `campaign` and `adgroup`, group by them. You should see the names you typed, not the placeholders.
4. Complete a test conversion. In ClickFlare, check **Logs → Event Logs** to confirm it was recorded.
5. In X's **Events Manager**, check that the pixel or Conversion API event arrived.

***

## Cost

The template has no cost row. X doesn't pass cost in the URL, and ClickFlare has no X cost integration. Set the **Cost Model** on the campaign to **CPC** and enter your average cost per link click from X's reports. ClickFlare has no CPM cost model. If you buy on impressions, divide your spend by the visits ClickFlare recorded to get a cost per visit.

Enter that average as the cost value. ClickFlare then estimates cost per visit, and your ROI is only as accurate as that number. X's auction cost varies, so correct it regularly with a [manual cost upload](/docs/en/settings/manual-cost-upload.md) from X's reports. See [Cost Models](/docs/en/core-platform-concepts/cost-models.md).

***

## Troubleshooting

> **External ID is empty for X clicks**
>
> * The `external_id` row's TS Parameter was changed or removed. It must be `twclid`.
> * The URL in X isn't the ClickFlare campaign URL, or it was edited.
> * The visit didn't come from an ad click. X adds `twclid` to paid clicks.

> **Conversions show in ClickFlare but not in X**
>
> That's expected without the X Pixel or the Conversion API. ClickFlare doesn't send conversions to X. Check that the pixel's event code fires on your conversion page, or that your server calls X's Conversion API with the `twclid`.

> **The X Pixel doesn't attribute conversions**
>
> With **Redirect** tracking, `twclid` stops at your ClickFlare domain and never reaches the lander. Switch to **Direct** tracking, or rely on X's Conversion API with the External ID ClickFlare stored.

> **Campaign columns show the placeholder text**
>
> The placeholders (`CAMPAIGN_NAME`, `ADGROUP_NAME`) were not replaced in the URL pasted into X. X won't replace them. Edit the ad's URL with the real names.

For the general checklist, see [Conversions not showing](/docs/en/troubleshooting/conversions-not-showing.md).

***

**FREQUENTLY ASKED QUESTIONS**

> **Q1:** Why is the template almost empty?

**A1:** X has no URL macros and no postback URL. The only thing a template can do is read X's click ID, `twclid`, which it does.

> **Q2:** Can ClickFlare send conversions to X?

**A2:** No. ClickFlare has no X postback and no X Conversion API integration. Use the X Pixel, or call X's Conversion API from your own server.

> **Q3:** Is `twclid` useful if ClickFlare can't send it to X?

**A3:** Yes. It's the value X's Conversion API matches on. Storing it in ClickFlare means you can export it with your conversions and send them to X yourself.

> **Q4:** Should I use Redirect or Direct tracking with X?

**A4:** Direct, if you use the X Pixel, so `twclid` reaches your lander. Redirect works for click tracking and for the Conversion API route. See [Direct Campaign Tracking](/docs/en/campaigns/direct-campaign-tracking.md).

## Related

> **[Direct campaign tracking](/docs/en/campaigns/direct-campaign-tracking.md)**
>
> Send X traffic straight to your lander.

> **[Cost models](/docs/en/core-platform-concepts/cost-models.md)**
>
> How CPC, CPA and RevShare costs are calculated.

> **[Manual cost upload](/docs/en/settings/manual-cost-upload.md)**
>
> Correct estimated cost with X's actual spend.

> **[Conversions not showing](/docs/en/troubleshooting/conversions-not-showing.md)**
>
> The general checklist when conversions don't arrive.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.