How it Works: Shopify source for Segment

Updated on 2024-10-14

Shopify Segment integration

Littledata's Shopify to Segment connection 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:

  • 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
note:

Using a headless Shopify setup? Follow the setup steps for headless Shopify tracking with Littledata.

What can you 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.

tip:

Looking for complete property and event details? Don't miss the complete tracking schema in Google Sheets. Note: this can be uploaded directly into Segment Protocols.

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 Destinations.

Event NameDescription
Cart ViewedUser has viewed the /cart page
Page ViewedUser has viewed a page
Product List ViewedUser has viewed a product as they scroll down the collection page
Product ClickedUser has clicked a product within a product list
Product ViewedUser has viewed a product page
Product Image ClickedUser has clicked a product image
Product SharedUser has shared a product via social links
Products SearchedUser has searched for products (with search query)
Registration ViewedUser has viewed the /account/register page

* 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.

The source also respects GDPR-compliant cookie consent via a cookie banner, or popular consent management platforms such as OneTrust and TrustArc.

Server-side events

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

Event NameDescription
Product AddedUser has added a product to the cart, and left it in the cart for more than 10 seconds
Product RemovedUser has removed a product from the cart
Checkout StartedUser has started checkout
Checkout Step ViewedUser has viewed a step in the checkout
Checkout Step CompletedUser has completed a step in the checkout
Customer CreatedCustomer record was created on Shopify, normally after the first step of the checkout o
Payment Info EnteredUser has entered payment information on step 3 of the Shopify checkout
Coupon AppliedUser has applied a coupon. Sent with Checkout Step Completed or Order Completed
Order CompletedCustomer has completed an order **
Post Purchase UpsellCustomer accepts the upsell. Will contain only the newly added products.
Order CancelledAdmin has cancelled an order (including the cancel_reason)
POS Order PlacedUser has placed an order via Shopify POS
Customer EnabledUser confirms their email address (whether single or double opt-in) and their Shopify customer account has verified_email set as true
Fulfillment CreatedOrder fulfillment is created (including  statustracking_numbers and  tracking_urls where the shipping integration allows)
Fulfillment UpdatedOrder fulfillment status has changed (including statustracking_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 - 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 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 to build a customer profile in 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 and Braze.

Littledata includes the following traits with an Identify call:

Property NameDescriptionProperty Type
userIdThe chosen user identifier. This defaults to the Shopify Customer ID.Double
createdAtDate customer record was created.Date
customerLifetimeValueTotal spend of customer on the Shopify store.Double
default_address.streetThe customer's default street address.String
default.address.postalCodeThe customer's ZIP / post code.String
default_address.stateThe customer's state address.String
default_address.countryThe customer's country.String
descriptionCustomer notes.String
emailCustomer's email address.String
email_consent_stateIf the user has consented to email marketing (mapping to EmailMarketingState).String, Null
email_opt_in_levelLevel of user's opt in email marketing (mapping to MarketingOptInLevel).String, Null
firstNameCustomer's first name.String
lastNameCustomer's last name.String
phoneCustomer's phone number.String
purchaseCountNumber of orders by this customer.Integer
sms_consent_stateIf the user has consented to SMS marketing (mapping to SmsMarketingState).String, Null
sms_opt_in_levelLevel of user's opt in to SMS marketing (mapping to MarketingOptInLevel).String, Null
stateShopify customer state - enabled, disabled, invited to create an account or customer declined.String
tagsCustom tags applied to the customer,String
verified_emailWhether the customer has verified their email.Boolean

Support for email marketing destinations

Email marketing platforms such as KlaviyoIterable and Hubspot 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 with enhanced identity resolution for abandonment retargeting.

Alias calls

To support seamless customer tracking in analytics destinations such as MixpanelVero and Kissmetrics, 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. See the Track (eCommerce) tab of the event schema for exactly which properties are sent with which events.

PropertyDescriptionProperty Type
affiliationA comma-separated list of order tags. Untagged orders use ShopifyString
cart_idThe ID of the Shopify cart.String
checkout_idThe ID of the checkout session.String
"integrations"."Google Analytics".clientIdThe user's Google Analytics Client ID.String
"integrations"."Google Analytics".sessionIdThe user's Google Analytics Session ID.String
"integrations"."Actions Amplitude".session_idThe user's Amplitude Session ID.Number
context.ipThe user's IP address.String
couponComma-separated string of discount coupons used, if applicable.String
currencyThe currency of the order.String
discountThe discounted amount.Float
emailShopify email address (after checkout step 2), or email submitted on a storefront form.String
lifetime_revenue_littledataLifetime revenue of the customer in Shopify.String
location_idLocation ID of the Point of Sale.Integer
order_idThe ID of the order, defaulting to the Shopify order name.String
payment_methodThe payment method chosen for checkout.String
presentment_currencyThe user's local currency.String
presentment_totalThe order total in local currency.String
productsA list of all the product at that step of the funnel.Array
purchase_count_littledataTotal purchase count for the customer.Integer
revenueProduct revenue (excluding discounts, shipping and tax). *Float
sent_fromUnique property to identify events sent by Littledata.String
shippingShipping cost.Float
shipping_methodcuShipping method chosen for checkout.String
shopify_customer_id_littledataShopify’s identifier for the customer.Integer
source_nameThe source of the order (e.g. web, android, pos).String
stepCheckout step.Integer
subscription_revenueThe revenue associated with a Subscription Event.Float
subtotalTotal after discounts but before taxes and shipping.Float
taxThe amount of tax on the order.Float
totalTotal value of the order.Float
userIdChosen user identifier, defaulting to Shopify Customer ID.String
consent.categoryPreferencesConsent state of the userObject
categoryPreferences.AnalyticsUser accepted or not analytics trackingBoolean
categoryPreferences.AdvertisingUser accepted or not marketing trackingBoolean
categoryPreferences.FunctionalUser has preferences for trackingBoolean
categoryPreferences.DataSharingUser accepted or not sale of dataBoolean

*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:

PropertyDescriptionProperty Type
brandThe brand of the product (Shopify vendor)String
categoryThe category of the product (defaults to all)String
compare_at_priceThe product price before any discountString
couponCoupon code associated with the productString
image_urlThe URL of the first product imageString
list_idThe ID of the product collection (for List Views and Clicks)String
list_positionThe product position in the collection (for List Views and Clicks)Integer
nameProduct nameString
priceThe product priceFloat
product_idShopify product IDString
quantityThe quantity of this productInteger
product_propertiesCustom properties of purchased productsArray
shopify_product_idAlso Shopify product IDString
shopify_variant_idThe Shopify variant IDString
skuThe product SKUString
urlThe URL of the product pageString
variantThe product variant nameString

Subscription Events

All recurring orders in the Shopify checkout, from any subscription app, are tracked as Order Completed events.

Additional subscription lifecycle events via Littledata's Recharge connection are available in cloud mode destinations. See the Track (custom) tab of the event schema.

Event NameDescription
Subscription CreatedA customer has created a subscription (with status, order_interval_frequency and order_interval_unit)
Subscription UpdatedA customer has updated a subscription (with status, order_interval_frequency and order_interval_unit)
Subscription CancelledA customer has cancelled a subscription (with cancellation_reason and cancellation_reason_comments)
Subscription SkippedA customer has skipped an order
Subscription Charge FailedA recurring charge failed (with error_type)

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. Try using the Segment Inspector Chrome extension 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. 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.

Littledata's integration is compatible with Segment Consent Management.

Read more about this in our dedicated help article.

Advanced settings

You can customize Littledata's Shopify source from the data pipeline settings in the Littledata admin. The general settings affect how we handle details such as orders, products and pageviews. The more advanced settings include:

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.

View all available data pipeline settings >>>