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

# Next Commerce and ClickFlare Integration Guide

> Track Next Commerce orders in ClickFlare: pass the click ID in sub1 and report each order from the order.created webhook or a checkout_completed tracker.

![Next Commerce and ClickFlare Integration](https://mintcdn.com/clickflare/gS923ib4WFySqxSL/images/integrations/covers/next-commerce.png?fit=max\&auto=format\&n=gS923ib4WFySqxSL\&q=85\&s=3be8cc39e8a3624a7fd28e10ba1acdf9)

Next Commerce is an e-commerce platform for direct-to-consumer brands. It runs your storefront, checkout, upsells and subscriptions, and it saves marketing attribution with every order.

ClickFlare tracks the ad click. This guide connects the two so every Next Commerce order is attributed to the campaign, traffic source and ad that brought the buyer. The ClickFlare click ID goes into Next Commerce in the `sub1` parameter, Next Commerce stores it on the order, and the order comes back to ClickFlare in one of two ways:

* **Server-side (recommended):** the `order.created` webhook sends the order, with its attribution, to Zapier or Make, which calls your ClickFlare postback.
* **Browser:** a `checkout_completed` event tracker in your store calls the postback from the buyer's browser.

The server-side route is more reliable. It runs on Next Commerce's servers, so ad blockers and buyers who leave before the confirmation page loads don't lose the order, and Next Commerce retries it if the first delivery fails. It also covers orders from custom funnels built on the Admin API, as long as they pass the same attribution values.

***

## At a glance

To set up Next Commerce with ClickFlare:

1. Set up a tracking domain and campaign.
2. Create the store as an offer with sub1.
3. Create the catch URL and webhook.
4. Place a test order.
5. Send the postback.

Each step is explained in [Setup](#setup).

| | Next Commerce + ClickFlare |
| - | - |
| **How it connects** | order.created webhook via Zapier or Make, or event tracker |
| **What reaches ClickFlare** | Orders, order total incl. tax, order number |
| **Timing** | Real time, per conversion |
| **Key parameters** | `sub1={cf_click_id}`, `subaffiliate1`, `total_incl_tax`, `number` |
| **Works with** | Storefront checkout and product pages, Admin API funnels |
| **Good to know** | sub1 lives in a one-day AffiliateData cookie before the cart. |

***

## How the data flows

```text theme={null}
Ad click
  → https://trk.yourdomain.com/cf/r/CAMPAIGN?...
     (ClickFlare records the click and generates the click ID)
  → [optional lander → CTA uses the ClickFlare click URL]
  → https://yourstore.com/?sub1=CF_CLICK_ID
     (Next Commerce saves sub1 in the AffiliateData cookie,
      then on the cart and the order as subaffiliate1)
  → Buyer completes checkout

Server-side:
  → order.created webhook → Zapier or Make
  → https://trk.yourdomain.com/cf/cv?click_id=SUBAFFILIATE1&payout=TOTAL&txid=NUMBER&ct=sale

Browser:
  → checkout_completed event tracker
  → the same postback, called from the buyer's browser
```

| ClickFlare parameter | Next Commerce field | Notes |
| - | - | - |
| `click_id` | `attribution.subaffiliate1` | Filled from `sub1` on the link |
| `payout` | `total_incl_tax` | Order total including tax |
| `txid` | `number` | The order number |
| `ct` | Fixed text, for example `sale` | Must match a custom conversion |

***

## What you'll need

* A ClickFlare account with your **own tracking domain**. Shared domains get flagged by ad platforms and blocked by browsers. See [Tracking domains](/docs/en/settings/tracking-domains.md).
* Access to **Settings** in your Next Commerce store.
* For the server-side route: a Zapier or Make account. See the [Zapier](/docs/en/integrations/zapier-click-flare-integration-guide.md) and [Make](/docs/en/integrations/make-click-flare-integration-guide.md) guides.

***

## Setup

**1. Set up your own tracking domain**

Add a custom tracking domain such as `trk.yourdomain.com` before anything else. The postback is built on it. See [Tracking domains](/docs/en/settings/tracking-domains.md).

**2. Create the custom conversion (optional)**

Go to **Settings → Custom Conversions**, click **Add** and create **Sale** with the parameter `sale`, **Include in Conversions** and **Include in Revenue** turned on. Add **Upsell** (`upsell`) too if you report upsells separately. The value in `ct` must match exactly. See [Custom conversions](/docs/en/settings/custom-conversions.md).

**3. Create the campaign**

Go to **Campaigns → New Campaign**, pick your traffic source and tracking domain, and choose **Redirect** tracking. This setup needs the click ID in the URL that reaches Next Commerce, which a redirect campaign provides. See [Creating a campaign](/docs/en/campaigns/creating-a-campaign-in-click-flare.md).

**4. Create the store as an offer with sub1**

In the campaign path, create the offer inline with your store, product page or checkout link and the click ID in `sub1`:

```text theme={null}
https://yourstore.com/?sub1={cf_click_id}
```

A checkout link works too: `https://yourstore.com/checkout/add/?product=12:1&sub1={cf_click_id}`. Next Commerce reads attribution on storefront checkout and product pages.

> [!WARNING]
>
> Keep the braces: `{cf_click_id}`. Without them Next Commerce stores the literal text `cf_click_id` in `subaffiliate1`.

If you run a lander first, its CTA must link to the ClickFlare **click URL**. Save the campaign and use its URL in your ads.

**5. Choose how the order reaches ClickFlare**

Set up one of the two routes below. Don't run both, or each order is counted twice.

***

## Route 1: order.created webhook

Next Commerce sends webhooks as a fixed JSON body with its own field names, and the receiving URL must answer with a 200 status. Zapier or Make sits in between and turns it into a ClickFlare postback.

**1. Create the catch URL**

In Zapier, start a Zap with **Webhooks by Zapier → Catch Hook**. In Make, start a scenario with a **Custom webhook**. Copy the URL.

**2. Create the webhook in Next Commerce**

Go to **Settings → Webhooks** and choose **Create Webhook**. Paste the catch URL as the target and select the `order.created` event trigger. Save.

**3. Place a test order**

Click through your ClickFlare campaign URL and place an order. In Zapier or Make, open the received payload. Under `data`, find `number`, `total_incl_tax` and the `attribution` object with `subaffiliate1`, which should hold your click ID.

**4. Send the postback**

Add an action that calls your postback with a **GET** request (**Webhooks by Zapier → GET**, or Make's **HTTP → Make a request**):

```text theme={null}
https://trk.yourdomain.com/cf/cv?click_id=SUBAFFILIATE1&payout=TOTAL_INCL_TAX&txid=NUMBER&ct=sale
```

Map each placeholder to the field from the payload. Add a filter so the action only runs when `subaffiliate1` has a value; orders without a ClickFlare click have nothing to match. Turn the Zap or scenario on.

If a delivery doesn't get a 200 response, Next Commerce retries it up to 10 times over several days. Because the postback carries the order number as `txid`, a retried order replaces itself in ClickFlare instead of counting twice. You can check deliveries under **Settings → Webhooks**, then **Actions → Detail** on the webhook.

> [!NOTE]
>
> ClickFlare also accepts a JSON POST to `/cf/cv` with `cf_click_id`, `payout`, `txid`, `ct` and `param1` to `param20`, for example `{"cf_click_id": "SUBAFFILIATE1", "payout": "TOTAL_INCL_TAX", "txid": "NUMBER", "ct": "sale"}` with the same fields mapped. Either form works. Keep the order number in `txid`: it is what keeps retries from double counting. See [Postback parameters](/docs/en/tracking/click-flare-parameters-in-postback-urls.md).

***

## Route 2: checkout\_completed event tracker

Event trackers are JavaScript that runs in the buyer's browser and subscribes to storefront events. No Zapier or Make needed, but ad blockers can stop it, and it only covers storefront checkouts.

Go to **Settings → Tracking Events → Add Event Tracker** and paste:

```javascript theme={null}
analytics.subscribe("checkout_completed", event => {
  const order = event.data;
  const clickId = order.attribution && order.attribution.subaffiliate1;
  if (!clickId) return;

  const url = "https://trk.yourdomain.com/cf/cv"
    + "?click_id=" + encodeURIComponent(clickId)
    + "&payout=" + encodeURIComponent(order.total_incl_tax)
    + "&txid=" + encodeURIComponent(order.number)
    + "&ct=sale";

  new Image().src = url;
});
```

Replace `trk.yourdomain.com` with your tracking domain, and remove `&ct=sale` if you skipped the custom conversion. Event trackers are pure JavaScript, so don't wrap the code in `<script>` tags.

***

## Attribution behavior

How Next Commerce keeps the click ID decides which click gets the order:

* **Last click by default.** A returning visitor's new link overwrites the earlier values. To keep the first click instead, add `clear_attribution=false` to the offer URL. New values are then added next to the old ones, and a repeated key such as `sub1` still takes the newest value.
* **One-day cookie.** `sub1` is kept in the `AffiliateData` cookie, which expires after one day. A buyer who comes back later without a new click loses it.
* **Saved on the cart.** Attribution moves from the cookie to the store's database when a cart is created and linked to a customer, and from there onto the order.

You can use `sub2` to `sub5` for other values, for example `sub2={campaign_id}`. If you use a different sub for the click ID, change `subaffiliate1` to match in the postback.

***

## Upsells and test orders

* **Upsells:** order lines carry an `is_upsell` flag. If your funnel adds post-purchase upsells to the order after `order.created` fires, they won't be in that first payload. Test one upsell order and check whether it arrives as an `order.updated` event before you build on it. Send upsells with their own `ct=upsell` and a `txid` such as `NUMBER-upsell`.
* **Test orders:** Next Commerce's sample order data includes an `is_test` flag. If your payload has it, add a filter on it in Zapier or Make so test orders stay out of ClickFlare.
* **Currency:** `total_incl_tax` is in the order's currency. The `order.created` payload also has a `reporting_values` object with totals for reporting. If you sell in several currencies, check which one fits your ClickFlare offer currency.

***

## Verify the setup

**1. Click through the campaign**

Open the ClickFlare campaign URL. The Next Commerce URL should show `sub1=` followed by a long ID, not the text `{cf_click_id}`.

**2. Place a test order**

Complete checkout. For Route 1, check the webhook's delivery log. For Route 2, look in the browser's network tab for the request to `/cf/cv`.

**3. Check ClickFlare**

The order should appear on the campaign with its revenue. In **Logs → Event Logs**, check that `txid` is the order number.

***

## Troubleshooting

> [accordion] subaffiliate1 is empty on the order
>
> * The offer URL is missing `sub1={cf_click_id}`, or the lander CTA links straight to the store instead of the ClickFlare click URL.
> * More than a day passed between the click and the order, and the `AffiliateData` cookie expired.
> * A later visit through another link replaced the value (last click). Use `clear_attribution=false` if you want the first click kept.

> [accordion] Webhook deliveries fail
>
> The target must accept JSON and answer with 200 within about 20 seconds. Check the delivery log under **Settings → Webhooks**, and check that the Zap or scenario is turned on.

> [accordion] Orders are counted twice
>
> Both routes are active, or the postback has no `txid`. Keep one route and send the order number as `txid`.

> [accordion] Conversions arrive without a campaign
>
> The postback reached ClickFlare with a value that matches no click. Check that it sends `subaffiliate1`, not another sub field, and see [Troubleshooting S2S postbacks](/docs/en/tracking/troubleshooting-s2s-postback-url-in-clickflare.md).

***

## FAQ

> [accordion] Does ClickFlare integrate with Next Commerce?
>
> Yes. You pass the ClickFlare click ID in sub1, Next Commerce saves it on the order, and the order.created webhook or a checkout\_completed tracker reports the order to ClickFlare.

> [accordion] Can I use direct tracking for Google Ads?
>
> This setup needs the click ID in the link that reaches Next Commerce. With Google Ads, send the ad to a lander you control that runs the ClickFlare direct tracking script, and point its CTA at the ClickFlare click URL. ClickFlare then adds `sub1` on the way to the store. See [Direct tracking](/docs/en/tracking/direct-tracking-clickflare.md).

> [accordion] Are refunds reported?
>
> Not by this setup. It reports new orders only. Adjust refunds in ClickFlare if you need net revenue.

> [accordion] Can I send the order back to my traffic source?
>
> Yes. Once ClickFlare records the order, it can pass it to the traffic source through that source's postback or conversion API integration.

***

## Related

> [card] [Make](/docs/en/integrations/make-click-flare-integration-guide.md)
>
> Map webhooks to postbacks

> [card] [S2S postback](/docs/en/tracking/tracking-conversions-using-s2s-postback.md)
>
> How postbacks work

> [card] [Checkout Champ](/docs/en/integrations/track-checkout-champ-campaigns-through-click-flare.md)
>
> Another DTC checkout


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