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

# MGID as a Traffic Source

> Track MGID campaigns in ClickFlare: pass click data and cost with the MGID template and send conversions and revenue back with the S2S postback.

![MGID traffic source template](https://mintcdn.com/clickflare/oNlhH4HxR5JFsOiP/images/integrations/covers/templates/mgid.png?fit=max\&auto=format\&n=oNlhH4HxR5JFsOiP\&q=85\&s=0dcbe0fab4db8ad7abac1855ca83a315)

MGID is a native advertising network. It shows your ads (MGID calls them teasers) in recommendation widgets on publisher sites worldwide. This guide sets up MGID as a traffic source in ClickFlare. It covers passing MGID's click data and cost into your reports and sending conversions, with revenue, back to MGID so its optimization and your stats agree.

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

## At a glance

| | |
| - | - |
| **Ad formats** | Native ads (teasers) in publisher widgets |
| **Click ID macro** | `{click_id}`, mandatory for conversion tracking |
| **Conversion tracking** | S2S postback to `a.mgid.com` |
| **Payout passed back** | Yes, in the `r` parameter |
| **What you replace** | `YOUR_CLIENT_ID` and `REPLACE_EVENT_NAME` in the postback |
| **Multiple events** | Up to 3 conversion goals, one postback per goal |
| **Cost** | Passed per click with `{click_price}`. The MGID cost integration is more accurate. |
| **Conversion API** | No |

## How it works

**1. MGID sends the click**

A visitor clicks your teaser. MGID opens your ClickFlare campaign URL and fills in its macros: the click ID in `click_id`, the click price in `click_price`, plus the teaser, widget, campaign and other details.

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

ClickFlare saves the value of `click_id` as the visit's **External ID**, records the click price as the visit's cost, and redirects the visitor to your lander or offer.

**3. The conversion reaches ClickFlare**

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

**4. ClickFlare posts it back to MGID**

ClickFlare fires the MGID postback, replacing `{external_id}` with the stored MGID click ID and `{payout}` with the revenue. MGID matches it to the original click and records it under the goal named in `e`.

> [!NOTE]
>
> The mirror to keep straight: in the **campaign URL** you write *ClickFlare's* parameter (`click_id`) and *MGID's* macro (`{click_id}`). The template does this for you. In the **postback URL** you write *MGID's* parameter (`c`) and *ClickFlare's* token (`{external_id}`).

## Before you start

* **Set up your own tracking domain.** Run the campaign and the postback on your own custom domain. Shared domains get flagged by networks 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).
* **Plan your MGID conversion goals.** MGID allows up to three per campaign: a main goal and two additional ones. Goal names may contain only Latin letters and numbers, for example `purchase` or `lead1`. No spaces, underscores or dashes.
* **Decide which conversions MGID should receive.** MGID optimizes on what you send it. See [Tracking several events](#tracking-several-events).

***

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

1. Go to **Campaigns** and click **New**.
2. In **Traffic Source**, open the dropdown and click **+ New Traffic Source**.
3. Type `mgid` in the search box and select the **MGID** template.
4. Enter a **Name**, for example `MGID`.
5. Set **Cost currency** to the currency of your MGID account. The click price arrives in that currency.

The template fills in the **Parameters** table for you:

| Name | TS Parameter | TS Token (MGID macro) | ClickFlare Token | What it carries |
| - | - | - | - | - |
| cost | `click_price` | `{click_price}` | `{cost}` | The price of the click. See [Cost](#cost). |
| externalId | `click_id` | `{click_id}` | `{external_id}` | MGID's click ID. Required for the postback. |
| teaser\_id | `teaser_id` | `{teaser_id}` | `{trackingField1}` | The ad (teaser) |
| campaign\_id | `campaign_id` | `{campaign_id}` | `{trackingField2}` | The MGID campaign ID |
| widget\_id | `widget_id` | `{widget_id}` | `{trackingField3}` | The source site's widget, where the ad was shown |
| category\_id | `category_id` | `{category_id}` | `{trackingField4}` | The ad's category in MGID |
| geo | `geo` | `{geo}` | `{trackingField5}` | The countries targeted in the MGID campaign. Not the visitor's own country. |
| title | `title` | `{title}` | `{trackingField6}` | The ad title |
| referrer | `ref` | `{referrer}` | `{trackingField7}` | The URL the visitor came from. Note the parameter is `ref`. |

![The MGID template's Parameters table in ClickFlare, with MGID's macros pre-filled](https://mintcdn.com/clickflare/nZP6EuFBEVoKPMxM/images/integrations/templates/mgid/parameters.png?fit=max\&auto=format\&n=nZP6EuFBEVoKPMxM\&q=85\&s=058d436e94a68dda0442afa598c328ea)

Each tracking field becomes a column you can group reports by. `widget_id` is the one you will use most: it tells you which publisher placements convert, so you can block them or adjust their bids in MGID. `teaser_id` and `title` tell you which creative won.

For the visitor's real country, use ClickFlare's own geo data, not the `geo` column. MGID's `{geo}` repeats your campaign targeting.

> [!WARNING]
>
> Don't change or remove the `externalId` row. Without `{click_id}` in the campaign URL, ClickFlare has no MGID click ID to send back, and MGID cannot attribute any conversion.

To pass more MGID data, click **Add Parameter**, give it a name and parameter, and enter the MGID macro as the **TS Token**. ClickFlare assigns the next free tracking field. MGID also offers `{source}`, `{source_id}`, `{site_id}`, `{site_category}` and `{geo_region}`, among others. Check MGID's macro list before adding them.

## Step 2 – Set up the postback

The postback is what sends conversions to MGID. It lives on the traffic source, so every campaign that uses this MGID traffic source sends conversions the same way.

### Get your client ID and goal name from MGID

The template's postback needs two values from MGID: your client ID and the name of the conversion goal. MGID shows both in the postback URL it creates inside each campaign's conversion tracking settings.

1. In MGID, create a campaign, or open an existing one and click its edit icon.
2. Go to the **Conversion tracking** section and, on the **Tracking settings** tab, choose **Postback**.
3. Add your conversion goal and give it a name, for example `purchase`. Add up to two more goals if you track several events.
4. Optional: under the advanced settings, choose whether each goal counts unique or non-unique conversions. Unique is the default.
5. In the **Postback URLs** section, click **Get Postback URL** next to the goal and copy it.

The URL MGID gives you has this shape:

```text theme={null}
https://a.mgid.com/postback/CLIENT_ID?c={click_id}&e=purchase&r={revenue}
```

Note two values from it: the client ID after `/postback/`, and the goal name in `e`. You only need these two. The ClickFlare template already has the click ID and revenue tokens in place.

Keep the MGID tab open. You come back to it in Step 4.

### Add the template's postback in ClickFlare

1. Back in the **New Traffic Source** form, scroll to **Passing conversion info to traffic source**.
2. Turn on **Traffic source postback URL**. The template's postback appears:

```text theme={null}
https://a.mgid.com/postback/YOUR_CLIENT_ID?c={external_id}&e=REPLACE_EVENT_NAME&r={payout}
```

3. Replace the two placeholders:

| Placeholder | Replace with | Where to find it |
| - | - | - |
| `YOUR_CLIENT_ID` | Your MGID client ID | The value after `/postback/` in the URL from **Get Postback URL** |
| `REPLACE_EVENT_NAME` | The goal name, for example `purchase` | The goal you added in MGID's **Conversion tracking** section. It must match exactly. |

Leave `{external_id}` and `{payout}` as they are. ClickFlare fills them in. With client ID `12345` and the goal `purchase`, the result is:

```text theme={null}
https://a.mgid.com/postback/12345?c={external_id}&e=purchase&r={payout}
```

4. In the dropdown on the left, choose the ClickFlare event that should fire the postback. Keep **Conversions** to send every conversion. If your final action is a custom conversion (for example `purchase`), choose that instead.
5. Click **Save**. You are back in the campaign editor with the MGID traffic source selected.

![The Traffic source postback URL switched on, showing the MGID template's postback](https://mintcdn.com/clickflare/nZP6EuFBEVoKPMxM/images/integrations/templates/mgid/postback.png?fit=max\&auto=format\&n=nZP6EuFBEVoKPMxM\&q=85\&s=f520e0abf64b79fd248f1a7403143910)

Only `c` and `e` are mandatory. `r` is optional, but without it MGID doesn't know your revenue. MGID shows revenue in your account's currency, so send payouts in that currency. See [Multicurrency in ClickFlare](/docs/en/tracking/multicurrency-support-in-click-flare-how-it-works.md).

To learn what each postback token does, see [How to Configure a Traffic Source S2S Postback URL](/docs/en/tracking/how-to-configure-a-traffic-source-s2s-postback-url.md).

## 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. Redirect is the usual choice.
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 already contains every MGID macro from the template, for example `click_id={click_id}` and `click_price={click_price}`.

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 cannot be traced back to MGID.

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

## Step 4 – Create the campaign in MGID

1. Return to the MGID campaign from Step 2 and finish its targeting, budget and bid.
2. In the tracking link settings, make sure `click_id={click_id}` appears only once. The ClickFlare URL already carries it. Check the **Tracking link preview** to see the final link.
3. Click **Publish**.
4. Create your ads and paste the ClickFlare campaign URL into each ad's URL field.

Paste the URL exactly as ClickFlare gives it. MGID replaces each macro in curly braces when the ad is clicked. MGID also adds any macros you selected in its **Tracking Tags** block. Keep those from duplicating the ClickFlare parameters.

## Step 5 – Test the integration

MGID records test conversions separately from real ones.

1. In MGID, open the campaign's ads. Hover over an ad image and click the eye icon to open the preview.
2. Click the ad in the preview and complete the offer the way a real visitor would. Clicks from the preview are flagged as tests.
3. In ClickFlare, check the visit. The **External ID** should hold an MGID click ID, not the literal text `{click_id}`.
4. Go to **Logs → Postback Status** and filter by the campaign. A successful request to `a.mgid.com` confirms ClickFlare sent the postback.
5. In MGID, wait 5–15 minutes and check the **Test conversions** column in the campaign list. If it is missing, add it with **Columns**. It can take up to an hour.

The test conversion appears under the goal it was sent for: the main goal or one of the two additional goals.

***

## Tracking several events

MGID tracks up to three goals per campaign, for example a lead, a deposit and a purchase. Each goal has its own postback, with its own name in `e`:

```text theme={null}
https://a.mgid.com/postback/YOUR_CLIENT_ID?c={external_id}&e=lead&r={payout}
https://a.mgid.com/postback/YOUR_CLIENT_ID?c={external_id}&e=purchase&r={payout}
```

1. In MGID, add a goal for each step. Note each goal's name.
2. In ClickFlare, create a [custom conversion](/docs/en/settings/custom-conversions.md) for each step, for example `lead` and `purchase`.
3. On the MGID traffic source, click **+ Another postback URL** once per extra goal.
4. In each postback, paste the template's URL, replace `YOUR_CLIENT_ID` with your client ID and `REPLACE_EVENT_NAME` with that goal's name. Map each postback to its ClickFlare event: the `lead` custom conversion to the `e=lead` URL, `purchase` to `e=purchase`.
5. Test each goal. MGID shows test conversions under each goal separately.

> **Rules for MGID goals**
>
> * Three goals at most: a main goal and two additional ones.
> * One postback per goal. Don't combine goals in one URL.
> * Goal names use Latin letters and numbers only, and each name is unique.
> * The `e` value must match the goal name in MGID exactly.
> * Choose unique or non-unique counting separately for each goal.

> **Sending only one event**
>
> If MGID should only learn from your final sale, keep a single postback and map it to that event. Earlier steps (leads, add to carts) still show in ClickFlare. They just don't reach MGID.
>
> To send a postback only for some conversions, for example only those above a certain payout, use **Event filter** under the postback to add conditions.

## Cost

The template passes cost per click. MGID fills `{click_price}` with the price of each click, and ClickFlare stores it as the visit's cost. In the campaign editor, set the **Cost Model** to **Not Tracked**. With no cost integration connected, ClickFlare then takes the cost from the `click_price` value in the URL. A fixed CPC would ignore MGID's real bid. See [Cost Models](/docs/en/core-platform-concepts/cost-models.md).

`{click_price}` is an estimate. MGID notes that some clicks are discounted after the fact and never charged, so the URL can overstate your spend. MGID recommends its API for actual figures.

For exact spend, use ClickFlare's **MGID cost integration**. It pulls cost from MGID's API at campaign, content and publisher level. You need your MGID email, password, Client API ID and access token. Once the integration exists, select it under **Cost Integration** on the MGID traffic source and keep the campaign's Cost Model on **Not Tracked**. The integration then takes priority over the URL value. Set the integration's timezone to match your MGID account, or costs will drift between days. See [MGID Cost Integration](/docs/en/integrations/mgid.md).

To fix individual days by hand, use a [manual cost upload](/docs/en/settings/manual-cost-upload.md). See also [Traffic Source Cost Tracking](/docs/en/tracking/how-to-setup-traffic-source-cost-tracking.md).

## Delayed revenue

If you run search arbitrage (RSOC or AFD) behind MGID, the feed reports revenue hours or days after the click. To pass that revenue to MGID once it arrives, see [Sending Delayed Revenue to Traffic Sources](/docs/en/advanced-tracking-configuration/how-to-send-delayed-revenue-to-traffic-sources.md).

***

## Troubleshooting

> **MGID shows no test conversions**
>
> * `YOUR_CLIENT_ID` is still in the postback, or the client ID belongs to another MGID account. Copy it from MGID's **Get Postback URL**.
> * `REPLACE_EVENT_NAME` is still in the postback, or `e` doesn't match the goal name in MGID exactly.
> * The postback still uses MGID's `{click_id}` instead of ClickFlare's `{external_id}`. ClickFlare doesn't know `{click_id}` and sends it as literal text.
> * The test click wasn't made from the ad preview, so MGID didn't flag it as a test.

> **Conversions show in ClickFlare but not in MGID**
>
> * **Traffic source postback URL** is off on the MGID traffic source.
> * **Disable sending postbacks to traffic source** is on in the campaign.
> * The postback is mapped to a different event than the one the conversion logged. Check **Logs → Event Logs** to see which event was recorded.
> * Check **Logs → Postback Status**: a failed request shows the status code MGID returned.

> **MGID shows conversions with no revenue**
>
> The postback has no `r={payout}`, or `r` still holds MGID's `{revenue}`. Use ClickFlare's `{payout}`.

> **Cost in ClickFlare doesn't match MGID**
>
> `{click_price}` doesn't account for clicks MGID discounts later. Connect the [MGID cost integration](/docs/en/integrations/mgid.md) and match its timezone to your MGID account.

> **Widget or teaser columns are empty**
>
> The macros were not replaced, usually because the URL was edited or a parameter was duplicated by MGID's Tracking Tags. Paste the campaign URL from ClickFlare unchanged. See [Traffic Source Tokens Arriving Empty](/docs/en/troubleshooting/tokens-arriving-empty.md).

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

***

**FREQUENTLY ASKED QUESTIONS**

> **Q1:** Can I use the same MGID traffic source for all my MGID campaigns?

**A1:** Yes, if they use the same goal names. The postback is set once on the traffic source and every campaign using it sends conversions the same way. Create a second MGID traffic source only if a campaign needs different goals.

> **Q2:** Why is it called `click_id` in the campaign URL and `c` in the postback?

**A2:** They are two halves of the same value. ClickFlare reads MGID's click ID from its own `click_id` parameter. MGID expects it back in its own `c` parameter. Both names are fixed. Change neither.

> **Q3:** Can I rename my MGID goals later?

**A3:** Yes, but update the `e` value in the ClickFlare postback at the same time. A postback with an old goal name no longer matches.

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

**A4:** Redirect is the usual choice. Use Direct only if MGID must see your lander's domain as the destination. See [Direct Campaign Tracking](/docs/en/campaigns/direct-campaign-tracking.md).

> **Q5:** Do I need the `{click_price}` cost row if I use the cost integration?

**A5:** No harm in keeping it. With the Cost Model on **Not Tracked**, the integration takes priority and the `click_price` value is ignored. If you ever disconnect the integration, the URL cost takes over again.

## Related

> **[MGID cost integration](/docs/en/integrations/mgid.md)**
>
> Pull actual spend from MGID's API.

> **[Traffic source postbacks](/docs/en/tracking/how-to-configure-a-traffic-source-s2s-postback-url.md)**
>
> Every token you can use in a postback.

> **[Custom conversions](/docs/en/settings/custom-conversions.md)**
>
> Split leads and sales into separate events.

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


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