# Customer events and pixels

> Five Luxe custom events in Shopify's customer events: when each fires, the versioned customData contract, consent, and subscribing from a pixel.

Source: https://www.luxesets.com/docs/customer-events

## Turning them on

With **Settings > Data and integrations > Analytics events** on (off by default, on every Luxe plan), the storefront publishes five custom events to Shopify's customer events with `Shopify.analytics.publish(name, customData)`. Custom pixels and app pixels receive them like Shopify's own events. Luxe ships no web pixel of its own and needs no extra access scope.

The publishing script (`luxe-events.js`) loads after the page has loaded, only while the switch is on, and replays the moments it buffered since the page started, so an event from the first render is not lost. It needs the Luxe app embed. Nothing is published:

- on headless and Tapcart storefronts (they keep their own events; the theme's DOM events are on [window.Luxe.cart and events](https://www.luxesets.com/docs/storefront-api#events)),
- for B2B buyers Luxe steps aside for, since no Luxe script loads ([B2B buyers](https://www.luxesets.com/docs/storefront-api#b2b)),
- where `Shopify.analytics` does not exist on the page.

Merchant setup, with the GA4 and Meta pixels Luxe provides: [Luxe events in GA4 and Meta](https://www.luxesets.com/help/analytics-events).

## The events

| Event                          | Fires                                                                                                                                                              |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `luxe_set_built`               | Every slot of a Build-your-own or Fixed set is filled in the Bundle set builder, or a tray pick brings a Collection set to its minimum. Once per set per page view |
| `luxe_set_added`               | A set is added to the bag from the builder or the tray, or an edited set goes back in it (`edited: true`). Opening Edit set in a cart publishes nothing            |
| `luxe_gift_chosen`             | A shopper chooses a reward gift                                                                                                                                    |
| `luxe_upsell_added`            | Products are added from an upsell offer or the checkout offer                                                                                                      |
| `luxe_purchase_option_changed` | A set is switched between one-time and a subscription plan, or between plans, in the builder or the tray                                                           |

## customData

Every event's `customData` starts with two fields:

| Field     | Type   | Meaning                                                                                             |
| --------- | ------ | --------------------------------------------------------------------------------------------------- |
| `v`       | number | The contract version, `1`. A later version only adds fields                                         |
| `surface` | string | Where it happened, such as `kit_block`, `tray`, `drawer`, `gift_picker`, `bar`, `cart` or `product` |

Ids are Shopify's numeric ids as strings, and Luxe's own ids for sets, ladders, rungs and offers. Money is a decimal in the currency's own units (`49.5`, not cents).

### Set events

`luxe_set_built` and `luxe_set_added`:

| Field             | Type                                              | Meaning                                                                                 |
| ----------------- | ------------------------------------------------- | --------------------------------------------------------------------------------------- |
| `set_id`          | string                                            | The set's id, as `kitId` in `luxe:kit:added`                                            |
| `set_name`        | string                                            | The set's name; empty when the set is not on the page                                   |
| `set_type`        | string                                            | `build_your_own`, `collection` or `fixed`; empty when the set is not on the page        |
| `items`           | array of `{variant_id: string, quantity: number}` | The build: a builder's picks and fixed components, a tray's picks. At most 50 entries   |
| `value`           | number                                            | Luxe's predicted set price in the shopper's currency; absent while the set has no price |
| `currency`        | string                                            | The shopper's currency (ISO 4217)                                                       |
| `predicted`       | `true`                                            | Present with `value`: the storefront predicts, checkout decides the price               |
| `purchase_option` | string                                            | `luxe_set_added` only: `one_time` or `subscription`                                     |
| `edited`          | `true`                                            | `luxe_set_added` only, when an edited set went back in the bag                          |

### Gift, upsell and purchase option events

| Event                          | Field             | Type                                              | Meaning                                                                                                                                                     |
| ------------------------------ | ----------------- | ------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `luxe_gift_chosen`             | `ladder_id`       | string                                            | The rewards ladder                                                                                                                                          |
|                                | `rung_id`         | string                                            | The rung that offers the gift                                                                                                                               |
|                                | `rung_label`      | string                                            | The rung's label; empty when the page does not know it                                                                                                      |
|                                | `variant_id`      | string                                            | The gift chosen                                                                                                                                             |
| `luxe_upsell_added`            | `offer_id`        | string                                            | The upsell offer's id, or the checkout offer's                                                                                                              |
|                                | `offer_type`      | string                                            | `frequently_bought_together`, `pairs_well`, `quantity_breaks`, `make_it_a_set`, `refill`, `tier_gap`, `gift_addon`, `upgrade`, `drawer` or `checkout_offer` |
|                                | `placement`       | string                                            | `PRODUCT_PAGE`, `CART_DRAWER`, `REWARDS_BAR` or `SET_BUILDER` for an upsell offer; `drawer` for the checkout offer                                          |
|                                | `items`           | array of `{variant_id: string, quantity: number}` | The products added                                                                                                                                          |
|                                | `value`           | number                                            | Predicted, in the **shop** currency; absent when unknown                                                                                                    |
|                                | `currency`        | string                                            | The shop currency                                                                                                                                           |
|                                | `predicted`       | `true`                                            | Present with `value`                                                                                                                                        |
| `luxe_purchase_option_changed` | `set_id`          | string                                            | The set                                                                                                                                                     |
|                                | `from`, `to`      | string                                            | `one_time` or `subscription`                                                                                                                                |
|                                | `selling_plan_id` | string                                            | The plan chosen, when `to` is `subscription`                                                                                                                |

```json title="luxe_set_added"
{
  "v": 1,
  "surface": "kit_block",
  "set_id": "ck_sampler",
  "set_name": "Coffee sampler",
  "set_type": "build_your_own",
  "items": [
    { "variant_id": "44501", "quantity": 1 },
    { "variant_id": "44502", "quantity": 2 }
  ],
  "value": 36,
  "currency": "USD",
  "predicted": true,
  "purchase_option": "one_time"
}
```

**Never in an event:** customer data, a customer or cart token, Luxe's fee or Luxe-built revenue.

## Consent

Luxe does not gate the publish: Shopify's pixel manager applies each visitor's consent to each pixel, by the pixel's **Customer privacy** permission, exactly as for Shopify's standard events. A custom pixel set to **Required** with Analytics or Marketing receives nothing from a visitor who has not allowed it. Consent reaches Shopify from any banner that writes the Customer Privacy API (Shopify's own, or a consent app connected through its Shopify app).

Luxe's own analytics beacons are separate and keep their own analytics-consent gating.

## Subscribing from a custom pixel

In **Shopify admin > Settings > Customer events > Add custom pixel**:

```js title="Custom pixel"
const LUXE_EVENTS = [
  "luxe_set_built",
  "luxe_set_added",
  "luxe_gift_chosen",
  "luxe_upsell_added",
  "luxe_purchase_option_changed",
];

for (const name of LUXE_EVENTS) {
  analytics.subscribe(name, (event) => {
    const data = event.customData || {};
    if (data.v !== 1) return; // a version you have not mapped yet
    // Forward to your tool here, for example:
    // myTool.track(name, { set_name: data.set_name, value: data.value, currency: data.currency });
  });
}
```

Read fields by name and ignore the ones you do not know: a later version of the contract adds fields, it never renames or removes one.

## GA4 and Meta

The pixels Luxe provides (Copy custom pixel code in the app) map the events as follows. They stay **custom** events: Shopify's Google and Meta channels already send `add_to_cart` / `AddToCart` and the purchase, so mapping a Luxe event to a standard one would count the same change twice.

| Luxe event                     | GA4 (Tag Manager `event`)      | Meta (`trackCustom`)        |
| ------------------------------ | ------------------------------ | --------------------------- |
| `luxe_set_built`               | `luxe_set_built`               | `LuxeSetBuilt`              |
| `luxe_set_added`               | `luxe_set_added`               | `LuxeSetAdded`              |
| `luxe_gift_chosen`             | `luxe_gift_chosen`             | `LuxeGiftChosen`            |
| `luxe_upsell_added`            | `luxe_upsell_added`            | `LuxeUpsellAdded`           |
| `luxe_purchase_option_changed` | `luxe_purchase_option_changed` | `LuxePurchaseOptionChanged` |

The GA4 pixel pushes `luxe_set_id`, `luxe_set_name`, `luxe_set_type`, `luxe_offer_id`, `luxe_rung` (`rung_label`), `luxe_purchase_option` (`purchase_option`, else `to`), `luxe_item_count` (entries in `items`), `value` and `currency` to the data layer. The Meta pixel sends `set_name`, `set_type`, `offer_id`, `value` and `currency`.

## Analytics only

Anyone can publish a custom event from the browser console, so treat these events as analytics, never as proof of a purchase or a price. Money in them is Luxe's prediction; the order is the record of what was paid. Billing and Luxe's own reports never read them.
