> 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/client-side-events.md). Agents can also search and read this documentation through its [MCP server](https://docs.getpurpledot.com/~gitbook/mcp).

# Client-side tracking events

Look up Purple Dot browser event payloads and example analytics mappings.

The Purple Dot checkout dispatches `CustomEvent` objects on the storefront's `window`. Event data is in `event.detail`. Payload fields depend on the checkout integration and the information collected so far. Events are listed in storefront and checkout order.

The samples use `gtag` from an existing GA4 installation. Product names in the samples are placeholders for your storefront values. Money fields such as `price`, `total`, `shipping`, and `tax` are objects with `amount` and `currency`. Line items must match the schema your destination expects.

## `PurpleDot:Ready`

The event fires when the Purple Dot SDK is ready and initialized.

Example listener:

```javascript
window.addEventListener('PurpleDot:Ready', () => {
  console.log('PurpleDot SDK is ready!');
});
```

## `PurpleDot:LearnMoreClicked`

The event fires when a shopper clicks the "Learn More" link on the product detail page.

Payload fields:

* `placementType` - The type of placement
* `instanceId` - Unique identifier for this placement instance
* `skuId` - The SKU ID associated with the placement
* `sku` - The SKU object containing product information
* `displayCurrency` - The currency used for display
* `releaseId` - The waitlist ID for this placement

Example listener:

```javascript
window.addEventListener('PurpleDot:LearnMoreClicked', (event) => {
  console.log('Learn more clicked:', event.detail);

  // Send to GA4
  gtag('event', 'purple_dot_learn_more_clicked', {
    placement_type: event.detail.placementType,
    sku_id: event.detail.skuId,
    currency: event.detail.displayCurrency
  });
});
```

## `PurpleDot:AddToCart`

The event fires when a product is added to the cart as a pre-order.

Payload fields:

* `skuId` - Shopify's product variant ID of what got added to the cart
* `internalSkuId` - Purple Dot's own ID for the same, for matching Purple Dot records
* `releaseId` - The waitlist ID for this product
* `price` - The unit price as `{ amount, currency }`
* `quantity` - The quantity added to cart
* `productId` - The product ID, when available

Example listener:

```javascript
window.addEventListener('PurpleDot:AddToCart', (event) => {
  console.log('Added to cart:', event.detail);

  // Send to GA4
  gtag('event', 'add_to_cart', {
    currency: event.detail.price.currency,
    value: event.detail.price.amount * event.detail.quantity,
    items: [{
      item_id: event.detail.skuId,
      item_name: 'Product', // You may need to get this from your product data
      quantity: event.detail.quantity,
      price: event.detail.price.amount
    }]
  });
});
```

## `PurpleDot:RemoveFromCart`

The event fires when line items are removed from the cart.

Payload fields:

* `lineItems` - Array of line items in the cart
* `shipping` - Shipping information
* `shippingAddress` - Shipping address details
* `email` - Customer email
* `total` - Total cart value
* `tax` - Tax amount
* `discountCode` - Applied discount code
* `checkoutState` - Current state of checkout

Example listener:

```javascript
window.addEventListener('PurpleDot:RemoveFromCart', (event) => {
  console.log('Removed from cart:', event.detail);

  // Send to GA4
  gtag('event', 'remove_from_cart', {
    currency: event.detail.total.currency,
    value: event.detail.total.amount,
    items: event.detail.lineItems.map((item) => ({
      item_id: item.skuId,
      item_name: item.name,
      quantity: item.quantity,
      price: item.price.amount
    }))
  });
});
```

## `PurpleDot:CheckoutLoaded`

The event fires when the Purple Dot checkout interface is loaded.

Payload fields:

* `enableCombinedCart` - `true` when the combined checkout loads in a Liquid theme or browser SDK integration. It's absent for express checkout and for headless web-component integrations, where the event has no payload.

Example listener:

```javascript
window.addEventListener('PurpleDot:CheckoutLoaded', (event) => {
  console.log('Checkout loaded:', event.detail);

  // Send to GA4
  gtag('event', 'purple_dot_checkout_loaded', {
    combined_cart_enabled: event.detail?.enableCombinedCart
  });
});
```

The `shipping`, `tax`, and `discountCode` fields can be absent.

## `PurpleDot:PreorderCheckoutStep`

The event fires when a shopper progresses through a step in the pre-order checkout process.

Payload fields:

* `skuId` - The SKU ID for the pre-order
* `stepName` - Name of the current step
* `stepNumber` - Number of the current step
* `releaseId` - The waitlist ID for this pre-order
* `lineItems` - Array of line items
* `shipping` - Shipping information
* `shippingAddress` - Shipping address details
* `email` - Customer email
* `total` - Total order value
* `tax` - Tax amount
* `discountCode` - Applied discount code

Example listener:

```javascript
window.addEventListener('PurpleDot:PreorderCheckoutStep', (event) => {
  console.log('Preorder checkout step:', event.detail);

  // Send to GA4
  gtag('event', 'purple_dot_preorder_checkout_step', {
    step_name: event.detail.stepName,
    step_number: event.detail.stepNumber,
    sku_id: event.detail.skuId,
    value: event.detail.total.amount
  });
});
```

The `shipping`, `tax`, and `discountCode` fields can be absent. `stepNumber` is optional.

## `PurpleDot:PreorderCheckoutSubmitted`

The event fires when a pre-order checkout form is submitted.

Payload fields:

* `skuId` - The SKU ID for the pre-order
* `releaseId` - The waitlist ID for this pre-order

Example listener:

```javascript
window.addEventListener('PurpleDot:PreorderCheckoutSubmitted', (event) => {
  console.log('Preorder checkout submitted:', event.detail);

  // Send to GA4
  gtag('event', 'purple_dot_preorder_checkout_submitted', {
    sku_id: event.detail.skuId
  });
});
```

## `PurpleDot:PreorderCreated`

The event fires when a pre-order is successfully created.

Payload fields:

* `reference` - Pre-order reference number
* `email` - Customer email
* `shippingAddress` - Shipping address details
* `lineItems` - Array of line items
* `total` - Total order value
* `shipping` - Shipping information
* `tax` - Tax amount
* `discountCode` - Applied discount code

Example listener:

```javascript
window.addEventListener('PurpleDot:PreorderCreated', (event) => {
  console.log('Preorder created:', event.detail);

  // Send to GA4
  gtag('event', 'purchase', {
    transaction_id: event.detail.reference,
    value: event.detail.total.amount,
    currency: event.detail.total.currency,
    items: event.detail.lineItems.map((item) => ({
      item_id: item.skuId,
      item_name: item.name,
      quantity: item.quantity,
      price: item.price.amount
    }))
  });
});
```

## Related

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


---

# 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/client-side-events.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.
