You are helping connect a Fourthwall shop (fourthwall.com, hosted creator shop) to LinkJolt affiliate tracking.

## Context
- Merchant ID: YOUR_MERCHANT_ID
- Platform: Fourthwall
- Webhook URL: https://www.linkjolt.io/api/webhooks/fourthwall?merchant=YOUR_MERCHANT_ID
- Tracking Script: https://www.linkjolt.io/api/tracking.js?id=YOUR_MERCHANT_ID

LinkJolt can credit a Fourthwall sale from the affiliate's link alone: every LinkJolt affiliate link sends the visitor to the shop with utm tags (utm_source=linkjolt, utm_campaign = the campaign's tracking code, utm_content = the affiliate, utm_term = the click). When Fourthwall's checkout returns them on the order (`trackingParams`) in the Order Placed webhook, LinkJolt reads them there; confirm it with one test order through an affiliate link. A sale that used an affiliate's discount code is always credited to them.

## Step 1: Add the tracking script

In the Fourthwall dashboard: Site design > Style > Edit HTML code. Paste this line in the footer section and save:

```html
<script src="https://www.linkjolt.io/api/tracking.js?id=YOUR_MERCHANT_ID" async></script>
```

## Step 2: Create the webhook in Fourthwall

In the Fourthwall dashboard: Settings > For Developers, then Create Webhook. Paste this URL:

```
https://www.linkjolt.io/api/webhooks/fourthwall?merchant=YOUR_MERCHANT_ID
```

Choose the events **Order Placed** and **Order Updated** (if it takes one event per webhook, create a second one with the same URL). Order Updated tells LinkJolt when an order is cancelled or refunded, so its commission is taken back.

## Step 3: Save Fourthwall's verification key in LinkJolt

Fourthwall signs your webhooks with a verification key, shown on the same For Developers page. Copy it. In LinkJolt: Settings, Payment Providers, Create Webhook Secret, provider **Fourthwall**, paste the key.

## Step 4: Check it works

Open one of your affiliate links in a fresh browser window and place an order. An order Fourthwall marks as a test shows in LinkJolt under Commissions, Test sales, and is never paid; a real order shows under Commissions.

## Affiliate codes (optional)

Create each affiliate's discount code in Fourthwall, then add the same code in LinkJolt on the Coupons tab of the Campaigns page. A sale with that code is credited to the affiliate even without their link.

## Common issues

- "No sale recorded after a test order": the order must come through an affiliate link (or use an affiliate's code), and Fourthwall's verification key must be saved in Settings, Payment Providers. A test-mode order records as a test sale.
- "Invalid signature" alerts: the secret saved in LinkJolt is not the current one for this webhook. Copy it again from Fourthwall and save it.
- "The sale was credited to nobody": the affiliate's click was more than 30 days before the order, or the link was opened on a different device than the purchase and no code was used.
