Developer

Shopify Pixel integration

How the Apex Shopify Web Pixel maps Shopify customer events, dedupes event IDs, and buffers attribution.

The Apex Shopify Web Pixel runs inside Shopify's sandboxed pixel iframe. It subscribes to standard Shopify customer events, maps them to Apex events, and posts them to the Worker event pipeline.

Settings

The pixel receives settings from Shopify's webPixelCreate configuration:

SettingPurpose
shopIdPublic Apex shop ID on outgoing events.
endpointWorker base URL; the pixel posts to {endpoint}/events.
ingestShopIdShop ID covered by the signed ingest token.
ingestSignatureSigned pixel ingest token sent as _signature.
enabledEventsShopify event names Apex should forward.
trackPageViewedControls whether page_viewed is forwarded.
queueUnattributedMsTime to buffer events waiting for SDK assignment sync; default 3000 ms.
maxBufferedEventsMaximum buffered unattributed events; default 20.

Assignment sync

The storefront SDK publishes assignment state through the Shopify analytics bridge:

js
Shopify.analytics.publish("drip_assignment_sync", {
  visitorId: "visitor_demo_123",
  sessionId: "session_demo_123",
  assignments: [
    {
      experimentId: "22222222-2222-4222-8222-222222222222",
      variationId: "33333333-3333-4333-8333-333333333333"
    }
  ],
  qaMode: false
});

The pixel normalizes that payload, stores it in memory, and persists it best-effort to Shopify pixel local storage and a cookie named drip_assignment_sync_v1 for two hours.

Event mapping

Shopify eventApex event typeKey fields
checkout_completedgoalgoalId: "__revenue__", funnelStep: "purchase_completed", revenue, currency, order ID, line items
checkout_startedgoalgoalId: "__checkout_started__", checkout value fields
checkout_contact_info_submittedgoalgoalId: "__checkout_contact_info_submitted__"
checkout_address_info_submittedgoalgoalId: "__checkout_address_info_submitted__"
checkout_shipping_info_submittedgoalgoalId: "__checkout_shipping_info_submitted__"
payment_info_submittedgoalgoalId: "__payment_info_submitted__"
product_added_to_cartgoalgoalId: "__add_to_cart__", product, variant, price, quantity
product_removed_from_cartproduct_removed_from_cartProduct, variant, price, quantity
cart_viewedcart_viewedCart total and item count
product_viewedproduct_viewedProduct ID, title, type, vendor, price
collection_viewedcollection_viewedCollection ID and title
search_submittedsearch_submittedQuery and result count
page_viewedpageviewPage title and URL, only when trackPageViewed is true
alert_displayedalert_displayedMessage, alert type, area, target field, discount code when present
ui_extension_erroredui_extension_erroredError and extension metadata
drip_checkout_experiment_viewedexperiment_viewedCheckout-block experiment and variation IDs

Most mapped events add source: "shopify_pixel" in the event data before sending. The checkout-block view event uses source: "shopify_checkout_block" so checkout extension exposures stay distinguishable.

Event IDs and dedupe

The pixel creates stable IDs when Shopify or commerce data provides one:

  1. Shopify event id
  2. Shopify event eventId
  3. Shopify event clientId
  4. Mapped orderId
  5. Mapped order_id
  6. Mapped checkoutToken

Stable IDs use this shape:

text
shopify_pixel:{event_type}:{source_id}

If no stable source identifier exists, the pixel generates a random event ID. The Worker performs bounded event ID dedupe before publishing to Tinybird.

Unattributed buffer

When no assignment sync is available yet, the pixel builds an unattributed event with visitorId: "shopify_anonymous" and needs_attribution: true.

If buffering is enabled, the event is kept in memory until assignment data arrives or queueUnattributedMs expires. When assignments arrive, the buffer replays each queued event with needs_attribution: false and one event per active assignment. If the timer expires, the buffer drains as unattributed.

The perf_shopify_pixel_buffer_v1 assignment flag can disable buffering by setting it to false.