> For the complete documentation index, see [llms.txt](https://help.littledata.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.littledata.io/integrations/shopify-to-segment/how-it-works.md).

# How it works: Shopify source for Segment

The events, properties and identity calls Littledata sends from Shopify to Segment, and the settings that control them.

This page lists what Littledata tracks when you use Shopify as a Segment source. Use it as a reference for the events, properties and identity calls you will see in Segment and in your connected destinations.

<figure><img src="https://3956158252-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QhTbrMraNWciQeDvu1b%2Fuploads%2Fgit-blob-008284fe2b33473e3419e04aa40ffaeaac7b2620%2Fconnection-segment.png?alt=media" alt="Diagram of browser, server, metafield and channel data flowing through Littledata to Segment"><figcaption></figcaption></figure>

Littledata combines browser (client-side) and server-side tracking to capture what happens in your Shopify store: sales, marketing, customer and product data. Segment then passes that data on to your other tools. For example, a data warehouse like Snowflake, email tools like Klaviyo, Iterable and Braze, or analytics tools like Mixpanel.

### Client-side (device mode) tracking

When you [install the Segment connection](https://help.littledata.io/integrations/shopify-to-segment/installation), Littledata:

* Adds a small tracking script through the Littledata app embed in your Shopify theme.
* Loads Segment's analytics.js library on your storefront pages (not in the Shopify checkout).
* Sends device-mode ecommerce events to your Segment destinations.
* Passes the Segment anonymous ID and the Google Analytics client ID to Littledata's servers, so the user journey stays connected.

### Server-side (cloud mode) tracking

Littledata also adds webhooks to your Shopify store. When a customer interacts with your store, Shopify sends the change to Littledata, and Littledata sends it on to Segment. This means:

* Carts, checkout steps, orders and refunds are captured even when the browser script is blocked.
* Customer data (such as email) is sent securely from the server.
* No extra scripts run on the checkout pages.
* Marketing attribution still works when customers use ad blockers.
* You can use cloud-mode destinations, such as the [Meta Conversions API](https://help.littledata.io/integrations/shopify-to-segment/connect-segment-to-facebook-conversions-api).

{% hint style="info" %}
Using a headless Shopify setup? Follow the steps for [headless Shopify tracking](https://help.littledata.io/sources/shopify/headless-shopify/working-with-a-headless-shopify-setup).
{% endhint %}

### What you can track

These are the events Littledata sends from Shopify to Segment. They show up as tables in your warehouse and as regular events in your other Segment destinations.

You can turn off any of these events in the **Event Editor** tab of the Segment destination settings. See [data pipeline settings](https://help.littledata.io/advanced/developer/data-pipeline-settings).

{% hint style="info" %}
For a more detailed schema, contact <help@littledata.io>.
{% endhint %}

#### Device-mode events

Littledata sends these events through Segment's analytics.js library in the browser.

| Event name               | Description                                                  |
| ------------------------ | ------------------------------------------------------------ |
| Cart Viewed              | User viewed the /cart page                                   |
| Session Started\*        | User started a session                                       |
| Page (page call)         | User viewed a page                                           |
| Product List Viewed      | User viewed products as they scrolled down a collection page |
| Product Clicked          | User clicked a product in a product list                     |
| Product Viewed           | User viewed a product page                                   |
| Product Image Clicked    | User clicked a product image                                 |
| Product Shared           | User shared a product with social links                      |
| Products Searched        | User searched for products (with the search query)           |
| Registration Viewed      | User viewed the /account/register page                       |
| Thankyou Page Viewed\*\* | User viewed the thank you page, if available                 |

\*Session Started fires on the first visit in a browser session. It fires again for the same user only after they close the browser. Opening more tabs of your store does not send another Session Started.

\*\*This is less reliable than the de-duplicated Order Completed event sent from Littledata's servers. You can still use it to trigger a conversion in device-mode destinations. The `payment_method` and `shipping_method` properties are not sent with this event.

The source also respects [cookie consent](https://help.littledata.io/partner-recipes/cookie-consent-integrations/shopify-customer-consent-api) from Shopify's cookie banner or from consent apps such as [OneTrust](https://help.littledata.io/partner-recipes/cookie-consent-integrations/integrating-onetrust-shopify).

#### Server-side events

Littledata's servers track these events from Shopify and send them to Segment in cloud mode.

| Event name              | Description                                                                                                                               |
| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| Product Added           | User added a product to the cart                                                                                                          |
| Product Removed         | User removed a product from the cart                                                                                                      |
| Checkout Started        | User started checkout                                                                                                                     |
| Checkout Step Viewed    | User viewed a step in the checkout                                                                                                        |
| Checkout Step Completed | User completed a step in the checkout                                                                                                     |
| Payment Info Entered    | User entered payment information in the checkout                                                                                          |
| Customer Created        | Customer record was created in Shopify, usually after the first step of the checkout                                                      |
| Customer Enabled        | User confirmed their email address (single or double opt-in) and their Shopify customer has `verified_email` set to true                  |
| Customer Updated        | Customer record was updated in Shopify. This is sent as an Identify call, not a Track event                                               |
| Order Completed         | Customer completed an order                                                                                                               |
| Coupon Applied          | Order used a discount code. Sent with Order Completed or Post purchase upsell                                                             |
| Post purchase upsell    | Customer accepted a post-purchase upsell. Contains only the newly added products                                                          |
| POS Order Placed        | Customer placed an order through Shopify POS                                                                                              |
| Order Cancelled         | Admin cancelled an order (including the `cancel_reason`)                                                                                  |
| Order Refunded          | A refund was created for an order                                                                                                         |
| Fulfillment Created     | Order fulfillment was created (including `status`, `tracking_numbers` and `tracking_urls` when the shipping integration provides them)    |
| Fulfillment Updated     | Order fulfillment status changed (including `status`, `tracking_numbers` and `tracking_urls` when the shipping integration provides them) |

### User identity

In the Littledata app, you can choose which field to send as the `userId` for known customers. The **User ID** setting is in the **Tracking customisation** tab of the Segment destination settings.

* **Shopify Customer ID (default):** best for a simple Shopify setup with few integrations.
* **Email:** use this when other platforms use the plain email and can't hash it, and you are comfortable with the privacy trade-off.
* **MD5 Hashed Email:** useful when other marketing tools send traffic where you know the visitor's email but not their Shopify customer ID. Littledata lowercases the email and uses an unsalted MD5 hash, so it matches hashes from your other sources.
* **None:** choose this if your own Segment setup already handles user identity and you only need the extra events from Littledata.
* [**Customer metafield**](https://help.littledata.io/integrations/shopify-to-segment/customer-metafields-as-userid-for-segment): if you store your own customer identifier in a Shopify customer metafield, Littledata can send it as the `userId`.

For Segment Unify, Littledata also sends `shopify_customer_id` as an [external ID](https://segment.com/docs/unify/identity-resolution/externalids) for better matching.

#### Identify calls

When an event belongs to a known Shopify customer, Littledata also sends an [Identify call](https://segment.com/docs/connections/spec/identify). This builds the customer profile in [Unify](https://segment.com/docs/unify) and updates CRM tools connected to Segment.

Identify calls are sent when the customer logs in to the storefront, with orders, when a customer is created, and when the customer record is updated in Shopify admin. This helps identity resolution in destinations such as [Klaviyo](https://segment.com/docs/connections/destinations/catalog/klaviyo) and [Braze](https://segment.com/docs/connections/destinations/catalog/braze).

Server-side Identify calls include these traits:

| Trait                        | Description                                                                                                                                              | Type         |
| ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ |
| `id`                         | Shopify customer ID. The `userId` of the call follows your **User ID** setting                                                                           | Integer      |
| `createdAt`                  | Date the customer record was created                                                                                                                     | Date         |
| `customerLifetimeValue`      | Total spend of the customer in your Shopify store                                                                                                        | Float        |
| `default_address.street`     | Customer's default street address                                                                                                                        | String       |
| `default_address.city`       | Customer's city                                                                                                                                          | String       |
| `default_address.postalCode` | Customer's ZIP or post code                                                                                                                              | String       |
| `default_address.state`      | Customer's state or province                                                                                                                             | String       |
| `default_address.country`    | Customer's country                                                                                                                                       | String       |
| `description`                | Customer notes                                                                                                                                           | String       |
| `email`                      | Customer's email address                                                                                                                                 | String       |
| `email_consent_state`        | Whether the customer agreed to email marketing (maps to [EmailMarketingState](https://shopify.dev/docs/api/customer/unstable/enums/EmailMarketingState)) | String, Null |
| `email_opt_in_level`         | How the customer opted in to email marketing (maps to [MarketingOptInLevel](https://shopify.dev/docs/api/customer/unstable/enums/MarketingOptInLevel))   | String, Null |
| `firstName`                  | Customer's first name                                                                                                                                    | String       |
| `lastName`                   | Customer's last name                                                                                                                                     | String       |
| `phone`                      | Customer's phone number                                                                                                                                  | String       |
| `purchaseCount`              | Number of orders by this customer                                                                                                                        | Integer      |
| `sms_consent_state`          | Whether the customer agreed to SMS marketing (maps to [SmsMarketingState](https://shopify.dev/docs/api/customer/unstable/enums/SmsMarketingState))       | String, Null |
| `sms_opt_in_level`           | How the customer opted in to SMS marketing (maps to [MarketingOptInLevel](https://shopify.dev/docs/api/customer/unstable/enums/MarketingOptInLevel))     | String, Null |
| `state`                      | Shopify customer state: enabled, disabled, invited or declined                                                                                           | String       |
| `tags`                       | Custom tags on the customer                                                                                                                              | String       |
| `verified_email`             | Whether the customer verified their email                                                                                                                | Boolean      |

#### Email marketing destinations

Email tools such as [Klaviyo](https://segment.com/docs/connections/destinations/catalog/klaviyo/#server-side-track), [Iterable](https://segment.com/docs/connections/destinations/catalog/iterable/#track) and [HubSpot](https://segment.com/docs/connections/destinations/catalog/hubspot/#server) need an `email` property on server-side events to match them to a customer. They can't use an anonymous ID.

Littledata adds the `email` property whenever it knows the email: from the user's traits in the browser (device mode), or from the Shopify customer record (cloud mode).

Littledata also has a [direct Klaviyo integration](https://help.littledata.io/integrations/shopify-to-segment/shopify-segment-klaviyo) with better identity resolution for abandonment flows.

#### Alias calls

Analytics tools such as [Mixpanel](https://segment.com/docs/connections/destinations/catalog/mixpanel/#alias), [Vero](https://segment.com/docs/connections/destinations/catalog/vero/#alias) and [Kissmetrics](https://segment.com/docs/connections/destinations/catalog/kissmetrics/#alias) need an alias to join anonymous and known activity. When a server-side Identify call has both an `anonymousId` and a `userId`, Littledata also sends an Alias call that links them.

### Event properties

These properties may be included in the events listed above.

| Property                                    | Description                                                                                                                               | Type    |
| ------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| `affiliation`                               | Order tags or sales channel of the order                                                                                                  | String  |
| `cart_id`                                   | ID of the Shopify cart                                                                                                                    | String  |
| `checkout_id`                               | ID of the checkout                                                                                                                        | Integer |
| `integrations.Google Analytics.clientId`    | The user's Google Analytics client ID                                                                                                     | String  |
| `integrations.Google Analytics.sessionId`   | The user's Google Analytics session ID                                                                                                    | String  |
| `integrations.Actions Amplitude.session_id` | The user's Amplitude session ID                                                                                                           | Number  |
| `integrations.Facebook Pixel.fbp`           | The user's Meta browser ID                                                                                                                | String  |
| `integrations.Facebook Pixel.fbc`           | The user's Meta click ID                                                                                                                  | String  |
| `integrations.Braze.braze_id`               | The user's Braze ID                                                                                                                       | String  |
| `integrations.TikTok Pixel.ttp`             | The user's TikTok Pixel ID                                                                                                                | String  |
| `integrations.TikTok Pixel.ttclid`          | The user's TikTok click ID                                                                                                                | String  |
| `context.ip`                                | The user's IP address (last part masked if **Anonymize IP** is on)                                                                        | String  |
| `context.market.id`                         | The Shopify Market ID for this event                                                                                                      | Number  |
| `context.market.handle`                     | The Shopify Market handle for this event                                                                                                  | String  |
| `context.consent.categoryPreferences`       | The user's consent choices: `Analytics`, `Advertising`, `Functional` and `DataSharing` (true or false)                                    | Object  |
| `coupon`                                    | Comma-separated list of discount codes used, if any                                                                                       | String  |
| `currency`                                  | The store currency of the order                                                                                                           | String  |
| `discount`                                  | Value of the discount applied                                                                                                             | Float   |
| `email`                                     | Customer email from Shopify, or an email submitted in a storefront form                                                                   | String  |
| `lifetime_revenue_littledata`               | Lifetime revenue of the customer in Shopify                                                                                               | String  |
| `location_id`                               | Location ID of the point of sale                                                                                                          | String  |
| `order_id`                                  | ID of the order. Defaults to the Shopify order name (set with **Order identifier**)                                                       | String  |
| `payment_method`                            | Payment method chosen in checkout                                                                                                         | String  |
| `presentment_currency`                      | The customer's local currency                                                                                                             | String  |
| `presentment_amount`                        | Order total in the customer's local currency (server-side order events)                                                                   | String  |
| `presentment_total`                         | Order total in the customer's local currency (Thankyou Page Viewed)                                                                       | String  |
| `products`                                  | List of the products at that step of the funnel                                                                                           | Array   |
| `profit_value`                              | Estimated profit of the order, sent when [Profit Signal](https://help.littledata.io/sources/profit-signal/how-to-use-profit-signal) is on | Float   |
| `profit_margin_applied`                     | Average profit margin applied across the order items, sent when Profit Signal is on                                                       | Float   |
| `purchase_count_littledata`                 | Total number of purchases by the customer                                                                                                 | Integer |
| `revenue`                                   | Product revenue (excluding discounts, shipping and tax)\*                                                                                 | Float   |
| `sent_from`                                 | Identifies events sent by Littledata                                                                                                      | String  |
| `shipping`                                  | Shipping cost                                                                                                                             | Float   |
| `shipping_method`                           | Shipping method chosen in checkout                                                                                                        | String  |
| `shopify_customer_id_littledata`            | Shopify's ID for the customer                                                                                                             | Integer |
| `source_name`                               | Source of the order (for example web, android, pos)                                                                                       | String  |
| `step`                                      | Checkout step                                                                                                                             | Integer |
| `subtotal`                                  | Total after discounts, before taxes and shipping                                                                                          | Float   |
| `tax`                                       | Tax on the order                                                                                                                          | Float   |
| `total`                                     | Total value of the order                                                                                                                  | Float   |

\*`revenue` is only sent with Order Completed, and only if you turn on **Include revenue on purchase events** in the **Tracking customisation** tab. Many Segment destinations treat `revenue` as a reserved property.

For events that are not linked to a Shopify Market, the browser tracker sends market ID `0` and handle `unassigned_market`.

#### Product properties

Each product in the `products` array, and the Product Viewed, Product Clicked and Product Added events, can have these properties:

| Property             | Description                                                                   | Type    |
| -------------------- | ----------------------------------------------------------------------------- | ------- |
| `brand`              | Brand of the product (Shopify vendor)                                         | String  |
| `category`           | Product type in Shopify                                                       | String  |
| `compare_at_price`   | Product price before any discount                                             | String  |
| `image_url`          | URL of the product image                                                      | String  |
| `list_id`            | Name of the product list (Product List Viewed and Product Clicked)            | String  |
| `position`           | Position of the product in the list (Product List Viewed and Product Clicked) | Integer |
| `name`               | Product name                                                                  | String  |
| `price`              | Product price                                                                 | Float   |
| `product_id`         | Product ID, set with the **Product identifier** setting                       | String  |
| `quantity`           | Quantity of this product                                                      | Integer |
| `product_properties` | Custom line item properties of purchased products                             | Object  |
| `profit`             | Estimated profit for this product, sent when Profit Signal is on              | Float   |
| `shopify_product_id` | Shopify product ID                                                            | String  |
| `shopify_variant_id` | Shopify variant ID                                                            | String  |
| `sku`                | Product SKU                                                                   | String  |
| `url`                | URL of the product page                                                       | String  |
| `variant`            | Product variant name                                                          | String  |

### Subscription events

All [recurring orders in the Shopify checkout](https://help.littledata.io/sources/shopify/tracking-subscription-orders-in-the-shopify-checkout), from any subscription app, are tracked as Order Completed events.

If you use Littledata's [Recharge connection](https://help.littledata.io/sources/recharge/overview), these subscription lifecycle events are also sent in cloud mode:

| Event name                 | Description                       |
| -------------------------- | --------------------------------- |
| Subscription Created       | Customer created a subscription   |
| Subscription Updated       | Customer updated a subscription   |
| Subscription Cancelled     | Customer cancelled a subscription |
| Subscription Skipped       | Customer skipped an order         |
| Subscription Charge Failed | A recurring charge failed         |

These events include the following properties, on top of the [standard event properties](#event-properties).

| Event property                 | Type   | Sent with                             |
| ------------------------------ | ------ | ------------------------------------- |
| `subscriptionId`               | number | All                                   |
| `products`                     | array  | All                                   |
| `status`                       | string | All except Subscription Charge Failed |
| `order_interval_frequency`     | number | All except Subscription Charge Failed |
| `order_interval_unit`          | string | All except Subscription Charge Failed |
| `subscription_revenue`         | number | All except Subscription Charge Failed |
| `cancellation_reason`          | string | Subscription Cancelled                |
| `cancellation_reason_comments` | string | Subscription Cancelled                |
| `error_type`                   | string | Subscription Charge Failed            |

### Using analytics.js with Littledata

To track other device-mode events, use the `analytics` object in the browser and call [Segment's `analytics.track` method](https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/#track). The [Segment Inspector Chrome extension](https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/#segment-inspector) helps you check that they are tracking.

You don't need to call `analytics.identify` or `analytics.alias`. Littledata already handles them.

To use third-party libraries that Segment loads on the page, use an [`analytics.ready()` callback](https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/#ready). Littledata may wait for the page to load and for cookie consent before it loads analytics.js, so those libraries may not be ready when your script runs.

### Segment Consent Management

Littledata works with [Segment Consent Management](https://segment.com/docs/privacy/consent-management/consent-in-segment-connections/). Read more in [Using Segment Consent Management with Shopify](https://help.littledata.io/integrations/shopify-to-segment/segment-consent-management).

### Market parameters

Events sent to Segment include the Shopify Market ID and handle in `context.market`. Because Segment feeds your other tools, the market flows through to every connected destination, whether that's a warehouse, an email platform like Klaviyo or Braze, or an analytics tool like Mixpanel. You can segment audiences, filter reports and trigger market-specific flows without extra data enrichment.

This needs Shopify Markets to be active in your store. You don't need any per-market settings in Littledata.

### Advanced settings

You can customize the Shopify source in the Segment destination settings. See all [data pipeline settings](https://help.littledata.io/advanced/developer/data-pipeline-settings).

{% stepper %}
{% step %}
**Open the Segment settings**

In the Littledata app, open **Settings** for your Segment destination.
{% endstep %}

{% step %}
**Open Tracking customisation**

Open the **Tracking customisation** tab and change the settings you need (see below).
{% endstep %}

{% step %}
**Save**

Click **Save** to apply your changes.
{% endstep %}
{% endstepper %}

The **Tracking customisation** tab includes:

* **Cookies to track:** cookies set on a landing page (for example a session ID or campaign name) are sent to Segment as traits in Identify calls.
* **CDN for analytics.js:** if you use a proxy CDN to load Segment's library from your own domain, enter the full CDN URL here.
* **Regional endpoint:** choose whether events go to Segment's **US** (North America) or **EU** (Europe) ingestion endpoint. This applies to both browser and server-side events. Learn more in [Segment's regional guide](https://www.twilio.com/docs/segment/guides/regional-segment).
* **User ID:** the customer identifier sent as `userId` (see [User identity](#user-identity)).
* **Include revenue on purchase events:** adds the `revenue` property to Order Completed.
* **Anonymize IP:** masks the last part of the customer's IP address.

### Related articles

* [Shopify to Segment installation guide](https://help.littledata.io/integrations/shopify-to-segment/installation)
* [Changing the data pipeline settings](https://help.littledata.io/advanced/developer/data-pipeline-settings)
* [Using Segment Consent Management with Shopify](https://help.littledata.io/integrations/shopify-to-segment/segment-consent-management)
* [Customer metafields as userId for Segment](https://help.littledata.io/integrations/shopify-to-segment/customer-metafields-as-userid-for-segment)
