Track swatch clicks in your pixels
Every swatch click is published as a customer event, so Google Analytics 4, Meta and other pixels can track it.
Updated Dec 2, 2026
When a shopper clicks a swatch, Combio publishes the click twice: as the cl:swatch_clicked customer event for the pixels in Shopify's Customer events settings, and as the cl:swatch-click event on the page for theme and tag manager scripts. Both carry the same data. There is nothing to turn on: Settings → Integrations → Customer events shows it as Always on.
When the event fires
On product pages and product cards, whenever a shopper clicks a swatch, button or dropdown value that leads to another product of the group. Clicking the product already shown sends nothing, and neither does the preview in Combio.
The data
| Field | Example | What it is |
|---|---|---|
productId | 8012345678901 | The clicked product's ID |
title | "Linen shirt - Red" | Its title |
value | "Red" | The swatch's value |
option | "Color" | The option name |
url | "/products/linen-shirt-red" | Its URL on your store |
price | 2500 | Its price in the currency's smallest unit: 2500 is 25.00 |
available | true | false when the product is sold out |
groupId | "0193a5c2-…" | The group's ID in Combio (in a group with several options, each option row has its own) |
surface | "product" | product for a product page, card for a product card |
position | 2 | The swatch's place in its row, counting from 1 |
These fields stay the same between app updates, so your tracking keeps working.
Send clicks to Google Analytics 4
- In Shopify, open Settings → Customer events and add a custom pixel.
- Paste the code below, with your GA4 measurement ID instead of
G-XXXXXXXXXX(twice). - Save the pixel and connect it.
const script = document.createElement("script");
script.src = "https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX";
script.async = true;
document.head.appendChild(script);
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag("js", new Date());
gtag("config", "G-XXXXXXXXXX", { send_page_view: false });
analytics.subscribe("cl:swatch_clicked", (event) => {
const click = event.customData;
gtag("event", "swatch_click", {
swatch_value: click.value,
swatch_option: click.option,
product_id: click.productId,
surface: click.surface,
position: click.position,
});
});send_page_view: false keeps this pixel from counting page views a second time when another app already sends them to GA4. To see the swatch fields in GA4's reports, register them as custom dimensions in GA4.
Shopify sends events to each pixel according to that pixel's customer privacy settings.
Other pixels
The same pattern works for any tool you can load in a custom pixel, such as Meta or TikTok: subscribe to cl:swatch_clicked and send event.customData to the tool.
Theme scripts and tag managers
Custom pixels run apart from your store's pages, so they use the customer event. Scripts that run on the page itself (your theme's code, or Google Tag Manager added to your theme) listen to the page event instead. Its data is in event.detail:
window.addEventListener("cl:swatch-click", (event) => {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({ event: "swatch_click", ...event.detail });
});For views and clicks without any setup, see Swatch analytics.
Was this article helpful?
Related articles
- Swatch analyticsSee how often shoppers see and click your swatches, on which devices and pages, which products they pick, and what they wanted while sold out.
- Connect your tools with the API and MCPCreate API tokens, manage product groups from your own scripts with the REST API, or let AI assistants such as Claude use them through MCP.