# How it Works: Shopify source for Segment

![Shopify to Twilio Segment](/files/m4WkfvWeenT9CFbTjaI8)

Littledata's [Shopify to Segment connection](broken://pages/LmulTGg2pFesTCBd1PgZ) uses a combination of client-side (browser) and server-side tracking to ensure 100% accurate data about your Shopify store in Segment. Littledata automatically integrates with Shopify and Shopify Plus sites to capture every customer touchpoint, including sales, marketing, customer and product performance data. You can send this data to a connected data warehouse like Snowflake; email and customer communications tools like Klaviyo, Iterable and Braze; analytics destinations such as Mixpanel and Kissmetrics; and many more destinations.

**Client-side (device mode) tracking**

During the [installation process](/integrations/shopify-to-segment/installation.md):

* A minified tracking script, loaded via Littledata's app embed in your Shopify theme
* Segment's analytics.js V2 library is loaded on all pages, except for the checkout
* Enables sending of device-mode ecommerce events to all Segment destinations
* Segment's anonymous ID and Google Analytics' client ID is passed to our servers to ensure consistent user journey tracking

**Server-side (cloud mode) tracking**

During the Segment connection setup, Littledata also adds a set of webhooks to your Shopify store. When a customer interacts with your store these changes are relayed server-side from Shopify to Littledata to Segment. The advantages to this approach are:

* 100% event capture for adds to cart, checkout steps, sales and refunds/returns
* Customer data (e.g. email) securely relayed server-side
* No extra scripts on the sensitive and secure checkout pages
* Accurate marketing attribution, even when customers use ad-blockers or cookie opt-outs
* Supports cloud-mode destinations such as [Facebook Conversions API](https://segment.com/docs/connections/destinations/catalog/facebook-pixel-server-side)

{% hint style="info" %}
Using a headless Shopify setup? Follow the setup steps for [headless Shopify tracking](/shopify/headless-shopify/working-with-a-headless-shopify-setup.md) with Littledata.
{% endhint %}

## What you can track

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

{% hint style="success" %}
For a more detailed schema and parameters, reach out to <help@littledata.io>.
{% endhint %}

### Device-mode events

Below is a table of events that Littledata sends to Segment through the analytics.js library. These events will show up as tables in your warehouse, and as regular events in your other device-mode Destination

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

\*Session started is triggered when a first visit of a user occured on a browser session. The next time it will be sent for the same user will be only after he closes the current browser. Opening more tabs of your store will **not** trigger an extra session start for the same browser.

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

You can *opt out* of any events in the [data pipeline settings](/advanced/developer/data-pipeline-settings.md).

The source also respects [GDPR-compliant cookie consent](/partner-recipes/cookie-consent-integrations/shopify-customer-consent-api.md) via a cookie banner, or popular consent management platforms such as [OneTrust](/partner-recipes/cookie-consent-integrations/integrating-onetrust-shopify.md).

### Server-side events

Server-side events are tracked by Littledata servers from Shopify and passed onto any destination in cloud mode.

| Event Name              | Description                                                                                                                             |
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| Product Added           | User has added a product to the cart, and left it in the cart for more than 10 seconds                                                  |
| Product Removed         | User has removed a product from the cart                                                                                                |
| Checkout Started        | User has started checkout                                                                                                               |
| Checkout Step Viewed    | User has viewed a step in the checkout                                                                                                  |
| Checkout Step Completed | User has completed a step in the checkout                                                                                               |
| Customer Created        | Customer record was created on Shopify, normally after the first step of the checkout o                                                 |
| Payment Info Entered    | User has entered payment information on step 3 of the Shopify checkout                                                                  |
| Coupon Applied          | User has applied a coupon. Sent with Checkout Step Completed or Order Completed                                                         |
| Order Completed         | Customer has completed an order \*\*                                                                                                    |
| Post Purchase Upsell    | Customer accepts the upsell. Will contain only the newly added products.                                                                |
| Order Cancelled         | Admin has cancelled an order (including the `cancel_reason`)                                                                            |
| POS Order Placed        | User has placed an order via Shopify POS                                                                                                |
| Customer Enabled        | User confirms their email address (whether single or double opt-in) and their Shopify customer account has `verified_email` set as true |
| Fulfillment Created     | Order fulfillment is created (including `status`, `tracking_numbers` and `tracking_urls` where the shipping integration allows)         |
| Fulfillment Updated     | Order fulfillment status has changed (including `status`, `tracking_numbers` and `tracking_urls` where the shipping integration allows) |

\*\* Order Completed event may be delayed by up to 40 seconds to wait for tags applied after the order was created

### User identity

In Littledata's app you can choose which of the following fields you want to send as the `userId` for known customers:

* **Shopify customer ID** (default) - Recommended if you have a simple Shopify setup with minimal integrations.
* **Hashed email** - The MD5 email hash is useful if you have other marketing platforms sending traffic where you know the email of the visitor (e.g. email marketing like Bronto or Marketo), but not their Shopify customer ID. We use an unsalted MD5 hash (`createHash` method) to match your other sources.
* **Email** - The email identifier is recommended when other platforms use the email and can’t hash it, and you are comfortable with the privacy implications.
* **None** (no identifier) - Choose “none” if user identity is already handled by your Segment implementation and you only need the extra events powered by Littledata's Shopify source.
* [**Shopify Customer metafield**](/integrations/shopify-to-segment/customer-metafields-as-userid-for-segment.md) - If you have your own customer identifier, and can add it to the Shopify customer record as a metafield, you can send this to Segment.

For Segment Unify we also send `shopify_customer_id` as an [externalID](https://segment.com/docs/unify/identity-resolution/externalids) for advanced matching.

### Identify calls

For every event where there is an identifiable Shopify customer (from both the client and the server) we also send an [Identify call](https://segment.com/docs/connections/spec/identify) to build a customer profile in [Unify](https://segment.com/docs/unify) and trigger updates in CRM systems connected to Segment. This identification happens when the customer logs into the storefront, on the last step of the checkout, with the order, and also after purchase with any customer update in Shopify admin.

This is especially helpful for identity resolution in common destinations such as [Klaviyo](https://segment.com/docs/connections/destinations/catalog/klaviyo) and [Braze](https://segment.com/docs/connections/destinations/catalog/braze).

Littledata includes the following traits with an Identify call:

| Property Name                | Description                                                                                                                                                | Property Type |
| ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |
| `userId`                     | The chosen user identifier. This defaults to the Shopify Customer ID.                                                                                      | Double        |
| `createdAt`                  | Date customer record was created.                                                                                                                          | Date          |
| `customerLifetimeValue`      | Total spend of customer on the Shopify store.                                                                                                              | Double        |
| `default_address.street`     | The customer's default street address.                                                                                                                     | String        |
| `default.address.postalCode` | The customer's ZIP / post code.                                                                                                                            | String        |
| `default_address.state`      | The customer's state address.                                                                                                                              | String        |
| `default_address.country`    | The customer's country.                                                                                                                                    | String        |
| `description`                | Customer notes.                                                                                                                                            | String        |
| `email`                      | Customer's email address.                                                                                                                                  | String        |
| `email_consent_state`        | If the user has consented to email marketing (mapping to [EmailMarketingState](https://shopify.dev/docs/api/customer/unstable/enums/EmailMarketingState)). | String, Null  |
| `email_opt_in_level`         | Level of user's opt in email marketing (mapping 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`          | If the user has consented to SMS marketing (mapping to [SmsMarketingState](https://shopify.dev/docs/api/customer/unstable/enums/SmsMarketingState)).       | String, Null  |
| `sms_opt_in_level`           | Level of user's opt in to SMS marketing (mapping to [MarketingOptInLevel](https://shopify.dev/docs/api/customer/unstable/enums/MarketingOptInLevel)).      | String, Null  |
| `state`                      | Shopify customer state - enabled, disabled, invited to create an account or customer declined.                                                             | String        |
| `tags`                       | Custom tags applied to the customer,                                                                                                                       | String        |
| `verified_email`             | Whether the customer has verified their email.                                                                                                             | Boolean       |

### Support for email marketing destinations

Email marketing platforms 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) require an `email` property with any server-side event in order to associate then with a customer (they cannot use an anonymous ID). Littledata's adds that `email` property whenever an email address is set in the user `traits()` object (in device-mode) or from the Shopify customer record (in cloud-mode).

Littledata also supports a [direct integration for Klaviyo](/integrations/shopify-to-segment/shopify-segment-klaviyo.md) with enhanced identity resolution for abandonment retargeting.

### Alias calls

To support seamless customer tracking in analytics destinations 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), Littledata ensures the pre-checkout `anonymousId` is added as an alias of the `userId` (used from checkout step 2 onwards).

### Event properties

These are the properties which may be included in the events listed above.

| Property                                    | Description                                                                  | Property Type |
| ------------------------------------------- | ---------------------------------------------------------------------------- | ------------- |
| `affiliation`                               | Comma-separated list of order tags. Untagged orders have the value `Shopify` | String        |
| `cart_id`                                   | ID of the Shopify cart                                                       | String        |
| `checkout_id`                               | ID of the checkout session                                                   | String        |
| `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 Facebok Pixel ID                                                  | String        |
| `integrations.Facebook Pixel.fbc`           | The user's Facebok click ID                                                  | String        |
| `integrations.Braze.braze_id`               | The user's Braze client 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                                                        | String        |
| `coupon`                                    | Comma-separated string of discount coupons used, if applicable               | String        |
| `currency`                                  | The currency of the order                                                    | String        |
| `discount`                                  | Value of the discount applied                                                | Float         |
| `email`                                     | Shopify default email address, or email submitted on a storefront form       | String        |
| `lifetime_revenue_littledata`               | Lifetime revenue of the customer in Shopify                                  | String        |
| `location_id`                               | Location ID of the Point of Sale                                             | Integer       |
| `order_id`                                  | The ID of the order, defaulting to the Shopify order name                    | String        |
| `payment_method`                            | The payment method chosen for checkout                                       | String        |
| `presentment_currency`                      | The user's local currency                                                    | String        |
| `presentment_total`                         | The order total in local currency                                            | String        |
| `products`                                  | A list of all the product at that step of the funnel                         | Array         |
| `purchase_count_littledata`                 | Total purchase count for the customer                                        | Integer       |
| `revenue`                                   | Product revenue (excluding discounts, shipping and tax) \*                   | Float         |
| `sent_from`                                 | Unique property to identify events sent by Littledata                        | String        |
| `shipping`                                  | Shipping cost                                                                | Float         |
| `shipping_method`                           | Shipping method chosen for checkout                                          | String        |
| `shopify_customer_id_littledata`            | Shopify’s identifier for the customer                                        | Integer       |
| `source_name`                               | The source of the order (e.g. web, android, pos)                             | String        |
| `step`                                      | Checkout step                                                                | Integer       |
| `subscription_revenue`                      | The revenue associated with a Subscription Event                             | Float         |
| `subtotal`                                  | Total after discounts but before taxes and shipping                          | Float         |
| `tax`                                       | The amount of tax on the order                                               | Float         |
| `total`                                     | Total value of the order                                                     | Float         |
| `userId`                                    | Chosen user identifier, defaulting to Shopify Customer ID                    | String        |
| `consent.categoryPreferences`               | Consent state of the user                                                    | Object        |
| `categoryPreferences.Analytics`             | User accepted or not analytics tracking                                      | Boolean       |
| `categoryPreferences.Advertising`           | User accepted or not marketing tracking                                      | Boolean       |
| `categoryPreferences.Functional`            | User has preferences for tracking                                            | Boolean       |
| `categoryPreferences.DataSharing`           | User accepted or not sale of data                                            | Boolean       |

\*`revenue` is available only with the Order Completed event, and only if the store opts in via the Littledata application. Revenue is a reserved property in many Segment destinations. Opting in overrides the `total` property sent to Google Analytics.

### Product properties

Each product in the `products` array, or Product Viewed and Product Added events, will have the following properties:

| Property             | Description                                                        | Property Type |
| -------------------- | ------------------------------------------------------------------ | ------------- |
| `brand`              | The brand of the product (Shopify vendor)                          | String        |
| `category`           | The category of the product (defaults to all)                      | String        |
| `compare_at_price`   | The product price before any discount                              | String        |
| `coupon`             | Coupon code associated with the product                            | String        |
| `image_url`          | The URL of the first product image                                 | String        |
| `list_id`            | The ID of the product collection (for List Views and Clicks)       | String        |
| `list_position`      | The product position in the collection (for List Views and Clicks) | Integer       |
| `name`               | Product name                                                       | String        |
| `price`              | The product price                                                  | Float         |
| `product_id`         | Shopify product ID                                                 | String        |
| `quantity`           | The quantity of this product                                       | Integer       |
| `product_properties` | Custom properties of purchased products                            | Array         |
| `shopify_product_id` | Also Shopify product ID                                            | String        |
| `shopify_variant_id` | The Shopify variant ID                                             | String        |
| `sku`                | The product SKU                                                    | String        |
| `url`                | The URL of the product page                                        | String        |
| `variant`            | The product variant name                                           | String        |

### Subscription Events

All [recurring orders in the Shopify checkout](/shopify/tracking-subscription-orders-in-the-shopify-checkout.md), from any subscription app, are tracked as Order Completed events.

Additional subscription lifecycle events via Littledata's [Recharge connection](https://www.littledata.io/shopify/recharge) are available in cloud mode destinations.

| 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 event properties in addition to the [standard event properties](#event-properties).

| Event property             | Property Type | With event                 |
| -------------------------- | ------------- | -------------------------- |
| `subscriptionId`           | string        | All                        |
| `items`                    | array         | All                        |
| `status`                   | string        | All                        |
| `order_interval_frequency` | number        | All                        |
| `order_interval_unit`      | string        | All                        |
| `value`                    | number        | All                        |
| `cancel_reason`            | string        | Subscription Cancelled     |
| `cancel_comment`           | string        | Subscription Cancelled     |
| `error_type`               | string        | Subscription Charge Failed |

## Using Analytics.js + Littledata

If you need to track device-mode events which are not covered above you can access the `analytics` object from within the browser, and use [Segment's `analytics.track` method](https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/#track). Try using the [Segment Inspector Chrome extension](https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/#segment-inspector) to check these are tracking.

You should not need to call `analytics.identify` or `analytics.alias` - this is already handled by Littledata.

To access third-party libraries loaded by Segment on the page, you should use an `analytics.ready()` [callback](https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/#ready). Littledata may wait for page load and cookie consent before loading Analytics.js, so those libraries may not be loaded by the time your additional script runs.

## Segment Consent Management

Littledata's integration is compatible with [Segment Consent Management.](https://segment.com/docs/privacy/consent-management/consent-in-segment-connections/)

Read more about this in our dedicated [help article](/integrations/shopify-to-segment/segment-consent-management.md).

## Advanced settings

You can customize Littledata's Shopify source from the [data pipeline settings](/advanced/developer/data-pipeline-settings.md) in the Littledata admin. The general settings affect how we handle details such as orders, products and pageviews. The following settings can be changed within the Segment connection, in the **tracking customization tab**:

**cookiesToTrack**

Any cookie set on a landing page (e.g. a session identifier or marketing campaign name) can be sent on to Segment with an identify call.

**CDNForAnalyticsJS**

If you have a proxy CDN setup to load Segment's AnalyticsJS library from your own domain you can specify it here.\
\
**Regional Endpoints**\
\
This settings allows you to change whether processed events are sent to Segment's **European** (Dublin) or **North American** ingestion endpoints. This enables your data to be split between the two servers, so it can be stored and processed by Segment more efficient.\
\
This setting affects both server-side and client-side tracking, therefore all your tracked events will be delivered to the selected endpoint. The setting allows you to select between US (North America) and EU (Europe), and all your data will be sent there.\
\
**For more information about how regional endpoints work for Segment, please reffer to** [**this article**](https://www.twilio.com/docs/segment/guides/regional-segment)**.**\\

View all available [data pipeline settings >>>](/advanced/developer/data-pipeline-settings.md)

For a more detailed schema and parameters, reach out to <help@littledata.io>.

## Market parameters in Littledata events

All events sent to Segment include the Shopify Market handle by default. Because Segment acts as a hub for your marketing stack, this flows through to every connected destination — whether that's a data warehouse, an email platform like Klaviyo or Braze, or an analytics tool like Mixpanel. This means you can segment audiences, filter reports, and trigger market-specific flows across your entire stack without any additional data enrichment. This requires Shopify Markets to be active on your store, but does not require any per-market destination configuration within Littledata.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.littledata.io/integrations/shopify-to-segment/how-it-works.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
