> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cometly.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Universe.com ticket purchase tracking

> Track Universe.com ticket purchases in Cometly with a browser event and a webhook, so every ticket sale is tied to the ad that produced it.

Use this setup to track Universe.com ticket purchases in Cometly and attribute them back to the correct ad or traffic source. It works by sending a custom browser event (an event you define yourself, sent from your website) with the Universe `ticket_id`, then matching that same `ticket_id` inside the Cometly webhook as the Tracking ID. A webhook is a message Universe sends to Cometly each time a ticket is sold.

Once it is running, each ticket sale carries the visit that led to it. You can see which ad, campaign or source sold your tickets, and decide where to spend based on real purchases.

## Before you start

* The Cometly pixel (the tracking script on your website) is installed on every page where the Universe checkout popup can open. See [Install the Cometly pixel](https://docs.cometly.com/getting-started/install-pixel.md).
* Universe's `embed2.js` script is on those same pages.
* You can open **Settings** in your Universe account to add a webhook.

## Why this matters

Universe purchases happen inside a popup checkout, so you cannot rely on a standard thank you page conversion.

This setup helps Cometly:

* capture the session and source data from the browser
* create an anonymous contact tied to that session
* match the final purchase data from the webhook
* attribute the conversion back to the correct ad, campaign or source

## How it works

When someone completes a purchase through the Universe checkout popup, two things happen.

### Browser side

Universe's embed script fires a JavaScript event called `unii:ticket:purchased`.

Your website listens for that event, grabs the `ticket_id`, and sends a **custom event** to Cometly (called "U Purchase" in this guide).

This custom event is **not** the actual purchase conversion. Its purpose is to:

* register an event on the anonymous contact
* store the session data
* save the `ticket_id` so Cometly can match it later

### Server side

Universe sends a webhook with the full purchase data.

Inside the webhook payload, the same ticket ID is available as `ticket.id`.

When configuring the Cometly webhook, map `ticket.id` from the Universe payload to the **Tracking ID** field (`tracking_id`) in Cometly.

Cometly then matches the incoming webhook event to the earlier browser event using that shared `tracking_id`.

## Step 1: Create a custom event in Cometly

First, create a custom event in Cometly: go to **Events Manager**, click **Manage custom events** and name one of the custom events (for example "U Purchase"). See [Custom events](https://docs.cometly.com/guides/events/custom-events.md) for the full steps.

Each custom event has an internal event name, shown under its name and in its setup panel, like:

* `custom_event_1`
* `custom_event_2`

You must use this internal event name when sending events from your website. For example, if your event shows as `custom_event_2`, that is what you use in your tracking script.

> [!TIP]
>
> The display name (like "U Purchase") is just for your reference. The actual event sent to Cometly must use the `custom_event_X` value shown in the setup panel.

This event should only be used for browser-side matching.

> [!WARNING]
>
> Do not use `Purchase` for the browser event. You send the real `Purchase` event server-side via webhooks.
>
> Using `Purchase` on both the browser and server would create duplicate conversions. Instead, use a custom event (like "U Purchase") on the browser to capture session data, and reserve `Purchase` for the webhook as the single, final conversion event.
>
> That gives you clean conversion tracking while still preserving attribution data from the original session.

**Optional:** Stop this event from being sent through the Conversion API (the connection that sends Cometly events back to your ad platforms) if you do not want it treated as a conversion. You manage this on the **Conversion API** tab of **Events Manager** (see the [Conversion API overview](https://docs.cometly.com/guides/conversion-api/overview.md)).

> [!TIP]
>
> In most cases, you should turn this off. The browser event is only used for session tracking and matching, while the actual conversion (like `Purchase`) should come from the webhook.

## Step 2: Add the tracking script to your website

Place this script on every page where the Universe checkout popup can be triggered.

It must be added:

* **after the Cometly pixel**
* **after Universe's `embed2.js` script**

Replace `custom_event_2` with the internal event name of your own custom event.

```html theme={null}
<script>
  document.addEventListener('unii:ticket:purchased', function(event) {
    var ticketId = event.detail && event.detail.ticket_id;
    if (ticketId) {
      comet('custom_event_2', { tracking_id: ticketId });
    }
  });
</script>
```

### What this script does

* listens for Universe's built-in `unii:ticket:purchased` event
* pulls the unique `ticket_id`
* sends your custom browser event (`custom_event_2` in this example) to Cometly
* stores that event on the anonymous contact along with the session and source data

## Step 3: Set up the Universe webhook

Create a webhook event in Cometly first so you have a webhook URL to give Universe. See [how to send event data using webhooks](https://docs.cometly.com/integrations/webhooks.md).

Then, in your Universe account:

1. Log in to **Universe**.
2. Go to **Settings**.
3. Open **Account**.
4. Scroll to **Webhooks**.
5. Click **Add Webhook**.
6. Enter your Cometly webhook URL.
7. Set a secret for verification.
8. Mark it **Active**.
9. Save.

Universe now sends a JSON webhook every time a ticket is purchased. The payload includes the ticket ID as `ticket.id`.

## Step 4: Configure the Cometly webhook mapping

When the Universe webhook is sent to Cometly, map the Universe payload fields into the Cometly fields.

The key part is this:

* map `ticket.id` from the Universe payload to **Tracking ID** in Cometly

This is what allows Cometly to match the purchase data to the earlier browser event.

> [!WARNING]
>
> The browser event and the webhook must use the exact same ID.
>
> * The browser event sends `tracking_id: ticketId`
> * The webhook maps `ticket.id` to **Tracking ID**
>
> If those values match, Cometly can connect the anonymous session to the final purchase event.

## Step 5: Use Purchase as the webhook event

The Cometly webhook you created for Universe should send your real conversion event, such as:

* **Purchase**
* or another revenue event you want to use

This webhook event is the actual conversion event. The browser custom event ("U Purchase") is only there for matching and session capture.

## Common mistakes

* using `Purchase` as the browser event
* forgetting to stop Conversion API sending for the browser custom event
* placing the script before the Cometly pixel or Universe script
* not mapping `ticket.id` to **Tracking ID** in the Cometly webhook
* using different ID values between the browser event and the webhook

## Check it worked

Buy a test ticket through the Universe checkout popup on your site. Then open the **Events Log** tab in [Events Manager](https://app.cometly.com/space/events-manager): the webhook event appears there within 60 seconds, with **SUCCESS** in the **Details** column.

## Frequently asked questions

### Does Cometly have a built-in Universe.com integration?

No. Universe.com connects to Cometly through the two parts in this guide: a custom event sent from your website and a webhook sent from your Universe account. Together they give Cometly the visit and the purchase, matched by the ticket ID.

### Why is my Universe.com test purchase not showing in Cometly?

Check that the webhook event is activated in Cometly. Test data sent before the webhook was activated is not processed and does not appear in your reports. If it is active, work through the list under Common mistakes above, starting with the script order and the **Tracking ID** mapping.

### How long does a Universe.com ticket purchase take to appear in Cometly?

Once the webhook event is active, a new purchase appears in the **Events Log** tab of **Events Manager** within 60 seconds of Universe sending it.

## Next steps

* [Send event data to Cometly with webhooks](https://docs.cometly.com/integrations/webhooks.md)
* [Manage custom events](https://docs.cometly.com/guides/events/custom-events.md)
* [Set up the Conversion API](https://docs.cometly.com/guides/conversion-api/overview.md)
* [How Order ID prevents duplicate purchases](https://docs.cometly.com/guides/tracking/order-id.md)

Still have questions or need a hand? We're happy to help. Reach our team at [support@cometly.com](mailto:support@cometly.com).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.