Skip to content
Log in

Analytics and conversion tracking with Customer Events

On this page

StoreConnect fires Customer Events when shoppers take actions on your store. You can read these events in Liquid and use them to send analytics and conversion tracking calls — for example, forwarding a purchase event to Google Analytics 4 or the Meta (Facebook) Pixel with the real order value. This guide covers the available events, how to read them, and how to connect them to your tracking providers.

Overview

A Customer Event represents an action a customer performs on the store. Liquid exposes events through the global current_events collection, where each entry is a CustomerEvent object with a type and optional event_data.

To read an event’s data you wrap it in the process_event block tag. The tag loads the event’s properties — and, for a purchase, the full order object — into scope for the duration of the block, then marks the event as handled so it fires only once.

You place this Liquid in a Content Block in your store’s Head Content, alongside the base tracking snippet for your analytics provider.

Available events

type When it fires Data available inside the block
cart.add A customer adds a product to their cart none
purchase A customer completes checkout and payment succeeds the order object

The purchase event exposes the full Order object as order, so you can send accurate transaction values.

Before you begin

How to read and handle events

Loop over current_events, wrap each one in {% process_event %}, and branch on event.type:

```liquid

{% for event in current_events %} {% process_event event %} {% if event.type == “purchase” %} {% elsif event.type == “cart.add” %} {% endif %} {% endprocess_event %} {% endfor %} ```

:::warning The type, event_data, and order values are only available inside the {% process_event %}...{% endprocess_event %} block. Reading current_events without the process_event tag returns no usable data, and the event will not be marked as handled. :::

Each event is handled exactly once. When the process_event block finishes, the event is marked as processed and will not appear in current_events on the next page load — so a purchase is not counted twice if the customer refreshes the confirmation page.

Example — Google Analytics 4

Add this to the same Content Block that holds your GA4 base snippet (gtag), in Head Content:

```liquid

{% for event in current_events %} {% process_event event %} {% if event.type == “purchase” %} {% elsif event.type == “cart.add” %} {% endif %} {% endprocess_event %} {% endfor %} ```

Example — Meta (Facebook) Pixel

Add this to the same Content Block that holds your Pixel base code (fbq):

```liquid

{% for event in current_events %} {% process_event event %} {% if event.type == “purchase” %} {% elsif event.type == “cart.add” %} {% endif %} {% endprocess_event %} {% endfor %} ```

Order values for the purchase event

Inside a purchase block, these properties are available on order:

Property Description
order.reference The order reference number — use as the transaction ID
order.order_number The human-readable order number
order.total Order total, including tax
order.sub_total Subtotal of order items, including exclusive taxes
order.total_tax Total tax for the order
order.total_shipping Total shipping charge
order.currency_code The currency used for the order

See the Order Liquid Object Reference for the full list of available properties.

Reference

Was this article helpful?

Was this article helpful?