> For the complete documentation index, see [llms.txt](https://docs.getpurpledot.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.getpurpledot.com/integrations/analytics/webhook-tracking.md). Agents can also search and read this documentation through its [MCP server](https://docs.getpurpledot.com/~gitbook/mcp).

# Tracking webhook events and settings

Look up analytics webhook events, payloads, authentication, and customer data settings.

The analytics **Webhook** connection sends checkout events to your HTTPS receiver. These events are for conversion tracking.

{% hint style="warning" %}
The `Purchase` event is sent when the shopper places the pre-order. When you release it, Purple Dot also creates an order in your e-commerce platform, and a connection that reads platform orders can record the sale again. After a test release, check that the new order doesn't duplicate the sale in your receiver's destinations. See [De-duplicating orders at release](https://docs.getpurpledot.com/understanding-purple-dot/pre-order-timing-and-your-reporting.md#de-duplicating-orders-at-release).
{% endhint %}

## Events

Events are listed in checkout order. Dispatch runs in background processing, with no fixed delivery delay.

| Shopper action            | `event_name`       | Typical destination event               |
| ------------------------- | ------------------ | --------------------------------------- |
| Item added to cart        | `AddToCart`        | `add_to_cart`                           |
| Checkout starts           | `InitiateCheckout` | `begin_checkout` or `initiate_checkout` |
| Payment details submitted | `AddPaymentInfo`   | `add_payment_info`                      |
| Pre-order created         | `Purchase`         | `purchase`                              |

## Connection settings

| Setting                                          | Meaning                                             | Default or requirement |
| ------------------------------------------------ | --------------------------------------------------- | ---------------------- |
| **Webhook URL** `Purple Dot checkout`            | Destination for JSON `POST` requests                | HTTPS required         |
| **Bearer Token** `Purple Dot checkout`           | Value sent in `Authorization: Bearer <token>`       | Optional               |
| **Shared Secret** `Purple Dot checkout`          | Secret used to sign the request body                | Optional               |
| **Send unhashed PII data** `Purple Dot checkout` | Send normalized contact details without hashing     | Off                    |
| **Accept** `Purple Dot checkout`                 | Acceptance of the linked API and webhook data terms | Required               |

## Request format

The request method is `POST` with `Content-Type: application/json`. A `2xx` response confirms receipt. The authorization header appears only when a bearer token is configured.

## Request signature

When **Shared Secret** is configured, `X-PurpleDot-Hmac-Sha256` contains a base64-encoded HMAC-SHA256 of the exact request body. Verification uses the same shared secret and the raw body before JSON parsing. A constant-time comparison checks the received signature against the expected one.

Example verification in Node.js:

```javascript
import { createHmac, timingSafeEqual } from 'node:crypto';

function verifySignature(rawBody, receivedSignature, sharedSecret) {
  if (typeof receivedSignature !== 'string') return false;
  const expected = createHmac('sha256', sharedSecret)
    .update(rawBody)
    .digest('base64');
  const received = Buffer.from(receivedSignature);
  const calculated = Buffer.from(expected);
  return received.length === calculated.length &&
    timingSafeEqual(received, calculated);
}
```

## Event fields

| **Field**                   | **Type** | **Required** | **Description**                                                                                                                |
| --------------------------- | -------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------ |
| `event_name`                | string   | Yes          | `Purchase`, `AddToCart`, `InitiateCheckout`, or `AddPaymentInfo`                                                               |
| `transaction_id`            | string   | Yes          | Unique ID for the event. On `Purchase`, this is your pre-order reference when available; on funnel events, a session event ID. |
| `event_time`                | string   | Yes          | ISO 8601 timestamp, for example `2024-01-15T12:00:00.000Z`                                                                     |
| `user_data`                 | object   | No           | Customer identifiers, hashed by default; see [Customer data](#customer-data)                                                   |
| `user_data.email`           | string   | No           | Customer email, SHA-256 hashed by default                                                                                      |
| `user_data.phone`           | string   | No           | Customer phone, SHA-256 hashed by default                                                                                      |
| `order`                     | object   | Yes          | Order / cart summary                                                                                                           |
| `order.reference`           | string   | No           | Pre-order reference (usually on `Purchase` only)                                                                               |
| `order.currency`            | string   | Yes          | Currency code, lowercased (for example `usd`)                                                                                  |
| `order.value`               | number   | Yes          | Total order value                                                                                                              |
| `order.contents`            | array    | No           | Line items (omitted if empty)                                                                                                  |
| `order.contents[].id`       | string   | Yes          | Product / variant ID (typically your Shopify variant ID)                                                                       |
| `order.contents[].quantity` | number   | Yes          | Quantity                                                                                                                       |
| `order.contents[].amount`   | number   | Yes          | Unit price                                                                                                                     |
| `click_ids`                 | object   | No           | Ad platform click IDs captured during checkout                                                                                 |
| `click_ids.fbc`             | string   | No           | Meta (`_fbc`)                                                                                                                  |
| `click_ids.ttclid`          | string   | No           | TikTok click ID                                                                                                                |
| `click_ids.gclid`           | string   | No           | Google Ads click ID                                                                                                            |
| `click_ids.gbraid`          | string   | No           | Google Ads iOS attribution                                                                                                     |
| `click_ids.wbraid`          | string   | No           | Google Ads web-to-app attribution                                                                                              |

`user_data`, `click_ids`, and `order.contents` are **omitted** when there is nothing to send.

## Purchase example

```json
{
  "event_name": "Purchase",
  "transaction_id": "998231",
  "event_time": "2024-01-15T12:00:00.000Z",
  "user_data": {
    "email": "a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3",
    "phone": "8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92"
  },
  "order": {
    "reference": "998231",
    "currency": "usd",
    "value": 99.5,
    "contents": [
      {
        "id": "45678901234",
        "quantity": 2,
        "amount": 49.75
      }
    ]
  },
  "click_ids": {
    "fbc": "fb.1.1234567890.AbCdEf",
    "gclid": "CjwKCAjw..."
  }
}
```

## Checkout example

```json
{
  "event_name": "InitiateCheckout",
  "transaction_id": "550e8400-e29b-41d4-a716-446655440000",
  "event_time": "2024-01-15T12:00:00.000Z",
  "order": {
    "currency": "usd",
    "value": 99.5,
    "contents": [
      {
        "id": "45678901234",
        "quantity": 2,
        "amount": 49.75
      }
    ]
  }
}
```

## Test payload

The connection test sends `event_id` rather than `transaction_id` and has no order or customer fields:

```json
{
  "event_name": "PurpleDotTestEvent",
  "event_id": "550e8400-e29b-41d4-a716-446655440000",
  "event_time": "2024-01-15T12:00:00.000Z"
}
```

## Customer data

By default, email addresses are trimmed, lowercased, and SHA-256 hashed. Phone numbers are converted to international E.164 format using the shopper's country when available, then SHA-256 hashed. Hashes use lowercase hexadecimal strings.

When **Send unhashed PII data** is on, email addresses and phone numbers use the same normalization and are sent without hashing. Empty `user_data`, `click_ids`, and `order.contents` are omitted.

## Related

* **Concept:** [How analytics integrations work](https://docs.getpurpledot.com/integrations/analytics/how-analytics-integrations-work.md#checkout-events)
* **Do this:** [Set up custom server-side tracking](https://docs.getpurpledot.com/integrations/analytics/custom-server-side-tracking.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.getpurpledot.com/integrations/analytics/webhook-tracking.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
