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

# Set up custom client-side tracking

Listen for Purple Dot browser events and send them to your own analytics tools.

Background: [How analytics integrations work](https://docs.getpurpledot.com/integrations/analytics/how-analytics-integrations-work.md#checkout-events).

{% hint style="warning" %}
Your listener reports the sale 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 analytics tool. 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 %}

## Before you start

* Your store uses the Purple Dot checkout.
* You can add JavaScript to the storefront and configure the destination analytics tool.
* Check whether a connected integration already sends the event you intend to track, to avoid duplicate purchases.

## Steps

1. Add a listener on the storefront's `window` object for each [browser event](https://docs.getpurpledot.com/integrations/analytics/client-side-events.md) you need. The payload is available as `event.detail`:

   ```javascript
   window.addEventListener('PurpleDot:PreorderCreated', (event) => {
     console.log('Pre-order created:', event.detail);
     // Map the payload to the event schema your analytics tool expects.
   });
   ```
2. Map the fields to your analytics tool. Replace example currency and product values with your storefront data. The [event reference](https://docs.getpurpledot.com/integrations/analytics/client-side-events.md) includes sample GA4 mappings.
3. Load your listeners before the shopper performs the actions you track.

## Verify

Complete a test pre-order with the browser console open. Confirm the listener receives `PurpleDot:PreorderCreated`, then confirm the mapped purchase arrives once in your analytics tool.

## Troubleshooting

* [My integration is not syncing](https://docs.getpurpledot.com/troubleshooting/orders-and-inventory/integration-is-not-syncing.md)

## Related

* **Concept:** [How analytics integrations work](https://docs.getpurpledot.com/integrations/analytics/how-analytics-integrations-work.md#checkout-events)
* **Look up:** [Client-side tracking events](https://docs.getpurpledot.com/integrations/analytics/client-side-events.md)
* **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/custom-client-side-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.
