# Campaign attribution

Source: https://gokarla.io/docs/guides/tracking-page/attribution

# Campaign attribution

Understanding which orders come from your tracking page campaigns is crucial
for measuring ROI and optimizing performance. Karla offers three attribution
methods with different trade-offs between setup effort, accuracy, and platform
support.

## Pick a method

| Method                                                      | Reliability | Setup     | Discount required | Platform support  | Best for                            |
| ----------------------------------------------------------- | ----------- | --------- | ----------------- | ----------------- | ----------------------------------- |
| [Referral parameter](#method-1-referral-parameter-tracking) | Basic       | Automatic | No                | Shopify, Shopware | Quick start, basic tracking         |
| [Discount codes](#method-2-discount-code-attribution)       | High        | Very low  | Yes               | All platforms     | Easy setup, discount campaigns      |
| [API attribution](#method-3-api-attribution-custom)         | Highest     | High      | No                | All platforms     | Custom implementation, full control |

## Method 1: Referral parameter tracking

:::warning Limited platform support

Currently supported on **Shopify** and **Shopware**. For other platforms, use
Method 2 (Discount Codes) or Method 3 (API Attribution).

:::

When customers click links from Karla (tracking pages, emails, push
notifications), a platform-specific referral parameter is added to the URL.
Your e-commerce platform captures it to identify Karla-originated orders.

**How it works:**

1. Customer clicks a Karla link (e.g., from a tracking email).
2. Karla automatically appends its attribution parameters to the URL.
   This happens transparently through the Karla app for your shop provider —
   you don't need to configure anything.
3. The parameters are captured during checkout.
4. Karla retrieves attributed orders via the platform's API.

The parameters carry more than just "this came from Karla" — they also encode
the **campaign** that was shown, the **specific product** the customer clicked
on (for product promotions), the **source** (tracking page, email, push), and
other contextual data. This lets you analyze performance per campaign and per
product in the portal, not just "Karla vs. everything else."

**Limitations:**

- **Platform-specific** — Shopify and Shopware only.
- May not work if the customer already has an active session with your shop.
- Tracking pages embedded as iframes won't appear in some platform analytics
  reports.

**Platform-specific guides:**

- [Shopify referral attribution](/docs/guides/shops/shopify#method-1-referral-parameter-refkarla)

:::tip Privacy by design
The attribution parameters are **not user-related** — they describe the
campaign, the clicked product, and the source, never the shopper. Karla
doesn't persist any user data as part of attribution.

On the browser side, parameters live in **session storage** only. They're
scoped to the current tab, cleared when the shopper closes it, never written
to cookies or long-lived storage, and never sent to any third party.

Because there's no user data and no persistent storage, you can decide which
consent level — if any — you want to gate attribution behind:

- **No consent required.** The most common choice for EU merchants: since the
  parameters are non-PII and live only for the duration of the session, many
  merchants treat attribution as strictly necessary for the post-purchase
  experience and enable it by default.
- **Functional consent.** Only append parameters when the shopper has
  accepted "functional" or "preferences" cookies.
- **Marketing/analytics consent.** Only append parameters when the shopper
  has opted in to marketing or analytics tracking — the strictest option,
  recommended if your legal team classifies campaign attribution as
  analytics.

You can wire any of these into the Karla Shopify app or your own storefront
logic — Karla will respect whatever consent rule you enforce. Talk to your
DPO or legal team to pick the level that fits your jurisdiction and policies.
:::

## Method 2: Discount code attribution

:::tip Easiest setup — works on all platforms

The simplest and most reliable attribution method when campaigns offer a
discount.

:::

Add a discount code to your campaign in the
[Karla portal](https://portal.gokarla.io). Orders using that code are
automatically attributed to the campaign.

**How it works:**

1. Configure the campaign with a discount code in the portal.
2. Ensure the discount code is **exclusive to this campaign**.
3. Customers apply the discount at checkout.
4. Karla tracks orders via the discount code.

**Benefits:**

- **No technical setup** — configure in the portal, works immediately.
- **Cross-platform** — works on Shopify, Shopware, WooCommerce, and custom
  stacks.
- Not affected by browser settings, ad blockers, or JavaScript.
- Easy to verify in your platform's order reports.
- Works regardless of session state or other plugins.

**Limitations:**

- Only works for campaigns that offer a discount.
- The discount must be exclusive to Karla for attribution to be accurate.
- **Over-attribution risk** — if customers share the code outside Karla
  (social media, coupon sites), those orders will be incorrectly attributed.

**Best practices:**

- **Create unique codes per campaign** so you can track performance
  individually.
- **Use time-limited codes** to minimize sharing and leakage.
- **Rotate discount codes** for ongoing campaigns.
- **Keep codes simple but unique** — e.g., `KARLA-WELCOME-DEC` instead of
  `SAVE10`.
- **Monitor for code sharing** by checking if attribution exceeds engagement
  metrics.

**Verification:**

- **Shopify:** Orders → filter by Discount code.
- **WooCommerce:** Orders → filter by Coupon code.
- **Custom platforms:** query orders by discount/coupon field.

## Method 3: API attribution (custom)

:::info For advanced users and all platforms

Full control over attribution — manually send attribution data via the Orders
API. Works on any e-commerce platform.

:::

For maximum flexibility, implement custom attribution tracking and send the
data to Karla via the
[Orders API](/docs/platform/orders#order-attribution).

**How it works:**

1. Capture attribution parameters in your own tracking system (URL params,
   cookies, session data).
2. When creating orders via the Karla API, include the `order_analytics`
   field.
3. Karla uses this data to attribute orders to your campaigns.

**Benefits:**

- **Works on all platforms** — Shopify, Shopware, WooCommerce, Magento,
  custom.
- **Full control** — implement exactly the attribution logic you need.
- **No JavaScript required** — server-side implementation.
- **Not affected by browser blockers** — tracking happens on your backend.
- **Highest reliability** — you control the entire attribution flow.

**Limitations:**

- **High setup complexity** — requires custom development.
- **Maintenance required** — you're responsible for the tracking logic.
- **API integration needed** — you must create/update orders via the Karla
  API.
- **Testing required** — you need to validate the attribution data flow.

**Best practices:**

1. **Always include source** — the `source` field is required (e.g.,
   `trackpages`, `email`, `sms`).
2. **Use consistent source values** — standardize identifiers across your
   implementation.
3. **Include campaign IDs** — use the `campaign` field to track specific
   campaign performance.
4. **Set appropriate medium** — use `transactional`, `promotional`, or
   `notification`.
5. **Sanitize URLs** — remove sensitive data from `landing_url` (passwords,
   tokens, PII).
6. **Capture early** — store attribution data at the start of the customer
   session.
7. **Include timestamp** — always set `captured_at` when attribution is
   detected.
8. **Test thoroughly** — verify attribution is working correctly in
   production.

**When to use this method:**

- You're on a platform not supported by Methods 1–2.
- You want complete control over the attribution process.
- You already have a custom order integration with Karla's API.

**Reference:**

- [Order Attribution API reference](/docs/platform/orders#order-attribution)

## When to use each method

:::tip Quick guide

- **Discount Codes (Method 2)** — perfect for promotional campaigns, seasonal
  sales, or when you need quick setup with good reliability on any platform.
- **API Attribution (Method 3)** — essential when you need custom attribution
  logic, full control, or tracking for non-discount campaigns.
- **Referral Parameter (Method 1)** — acceptable for initial testing on
  Shopify/Shopware, but upgrade to another method for production campaigns.

:::

## Analytics and A/B testing

Once attribution is set up, you get per-campaign analytics in the
[portal](https://portal.gokarla.io):

- **Impressions** — how many customers saw each campaign
- **Click-through rate** — engagement with the call-to-action
- **Conversion tracking** — purchases driven by the campaign
- **Revenue attribution** — direct sales impact

:::info Attribution affects analytics

Your chosen method directly impacts analytics accuracy:

- **Discount codes** — may show inflated conversions due to code sharing.
- **API attribution** — most accurate representation of true campaign
  performance.
- **Referral parameter** — may undercount due to session limitations.

:::

### A/B testing recommendations

- Use **API attribution** for the most accurate test results.
- Run tests for at least **7 days** to account for weekly patterns.
- Ensure sample sizes are statistically significant (**>100 orders per
  variant**).
- Test **one variable at a time** for clear insights.

## Related

- [Campaigns in the portal](/docs/guides/portal/campaigns) — create and manage
  campaigns.
- [Orders API](/docs/platform/orders#order-attribution) — full
  `order_analytics` reference.
