# Stripe Integration

> Learn how to integrate Stripe with AnyTrack for e-commerce conversion tracking. Set up payment event tracking, configure postback URLs, and enable accurate ROAS attribution for your campaigns.

## Stripe Integration Overview

1. When a visitor lands on your website, AnyTrack identifies the user and first-party data
2. AnyTrack autotags the Stripe payment link with required tracking data
3. When purchase completes, AnyTrack receives conversion data via webhook integration

## Stripe Payment Link Tracking

1. Append the `?client_reference_id=--CLICK-ID--` to your payment link.

```http http
https://buy.stripe.com/test_00g6qSh021cG5gc8ww?client_reference_id=--CLICK-ID--
```

When AnyTrack loads on your web page, it substitutes the placeholder `--CLICK-ID--` with a unique click ID.

2. Save your page and test the link to see if the parameter is appended to the link.

## Stripe Conversion Tracking Setup

1. Create a custom integration in AnyTrack
2. Open your Zapier or Make account
3. Create a new Zap:
   - App: Stripe
   - Event: Checkout Session Completed
4. Configure the action:
   - Webhook POST
   - Paste the AnyTrack webhook
   - Map the events and Event Attributes
   - Test, save, and publish

Alternatively, use the Webhook function within Stripe, select the `checkout.session.completed` event, and map the event parameters to AnyTrack Event Attributes.

Stripe sends webhook data in cents. Multiply the amount by 100 before sending it to AnyTrack.

---

## Data Mapping Between Stripe and AnyTrack

### Prerequisites

Before setting up data mapping, ensure:

1. Stripe Payment Link includes `?client_reference_id=--CLICK-ID--`
2. AnyTrack Tracking Tag/Tag installed and running on your website
3. The `client_reference_id` parameter contains the AnyTrack click ID

### Flow Overview

1. Visitor clicks a Stripe link tagged with AnyTrack's click ID
2. After successful payment, Stripe triggers a webhook or Zap
3. The webhook sends mapped data (including click ID and transaction info) to AnyTrack

### Zapier Integration Setup

#### Step 1: Trigger
- **App:** Stripe
- **Event:** `Checkout Session Completed`

#### Step 2: Format Value
- **App:** Formatter by Zapier
- **Action:** Numbers → “Perform Math Operation”
- **Formula:** `{{amount_total}} / 100` (convert cents to dollars)

#### Step 3: Webhook POST to AnyTrack
- **App:** Webhooks by Zapier
- **Action:** POST
- **URL:** AnyTrack Webhook endpoint (from your Custom Integration setup)
- **Payload Type:** JSON

**Field Mapping Example:**

| Stripe Field | AnyTrack Field | Description |
|---------------|----------------|--------------|
| `client_reference_id` | `clickid` | Links conversion to the AnyTrack visitor |
| `amount_total / 100` | `value` | Purchase amount (converted to dollars) |
| `currency` | `currency` | ISO currency code (e.g., `USD`) |
| `customer_details.email` | `email` | Customer email (optional) |
| `payment_status` | `status` | Payment status (e.g., `paid`) |
| `id` | `transaction_id` | Stripe’s transaction ID |

### Important Note

You cannot map event attributes directly through Stripe's native webhook. Use an intermediary automation service like Zapier or Make that can format and forward the payload correctly.

### Expected Outcome

Once configured:
- Stripe payments trigger conversions in AnyTrack
- Each conversion links to the correct visitor and campaign
- Conversions automatically forward to connected ad platforms

---

### The Webhook Payload Example:

```json
{
  "request": {"idempotency_key": null,"id": null},
  "data": {"object": {"client_reference_id": "p8qkMansHXKGTX9GmPTbMJ6GmSjTf4mUys","amount_total": 10000,"currency": "usd","payment_status": "paid","customer_details": {"email": "xxx@anytrack.io"},"id": "evt_1M5sv6JhmZq84NMqbCfCcgRL"}},
  "type": "checkout.session.completed"
}
```

## Related Articles

- [Advertising Integrations](/docs/advertising-integrations)
- [MediaGo Integration](/docs/mediago-ads-integration)
- [Outbrain Integration Checklist](/docs/outbrain-integration-verification-checklist)
