How it works: Shopify to Google Analytics 4

Updated on 2024-02-27

Server-side tracking for Google Analytics

Littledata's Shopify to Google Analytics 4 connection uses a combination of client-side (browser) and server-side tracking to ensure 100% accurate data about your Shopify store in Google Analytics 4. Littledata automatically integrates with Shopify and Shopify Plus sites to capture every customer touchpoint, including sales, marketing, customer and product performance data.

Client-side (browser) tracking

During the automatic installation process, Littledata adds a data layer and tracking script to all the store pages (the Littledata tracker uses script-tag, so no need to worry about theme changes).

  • LittledataLayer window-scope Javascript object is added on all pages, which you can also use with Google Tag Manager (GTM).
  • A minified tracking script, loaded via Littledata's app embed in your Shopify theme
  • Google's gtag library is then loaded on each page
  • Google's client ID (user identifier) is passed to our servers to ensure consistent user journey tracking
  • Fully compatible with Online Store 2.0

Server-side tracking

During the setup, Littledata also adds a set of webhooks to your Shopify store. This means that each time a user takes action our servers can relay that event to Google Analytics 4, ensuring 100% accuracy. There are many advantages to this approach:

  • Smaller script in the browser = faster page load
  • No scripts are loaded on the sensitive and secure checkout pages
  • Complete event capture for checkout flow, including sales, post-purchase upsells and refunds/returns
  • Avoids missed tracking or double tracking of the order status page
  • Accurate marketing attribution (sessions stitched together) across all checkout types
  • Data security and spam reduction: only authorised servers can feed into your data stream

What can you track

tip:

Complete tracking schema alongside parameter details can be found HERE

All the events below are tracked by default, but can be turned off and on during the setup or in the data pipeline settings.

Client-side events

Client-side events tracked by Littledata, via a script loaded within your Shopify theme.

Event NameDescription
page_viewUser has viewed a page
view_item_listUser has viewed a product link as they scroll down the page
select_contentUser has clicked a product within a product list
view_itemUser has viewed a product
clickUser has clicked a product image
shareUser has shared a product
view_cartUser has viewed the cart page
view_search_resultsUser has viewed the product that he searched for
sign_upUser has created an account on the store
loginUser has logged in an existing account

Server-side events

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

EventDescription
add_to_cartUser has added a product to the cart, and left it in the cart for more than 10 seconds
remove_from_cartUser has removed a product from the cart
begin_checkoutUser has started the checkout
add_shipping_infoUser has completed checkout step 1
add_payment_infoUser has completed checkout step 2
purchaseCustomer has completed a web order (excluding Point of Sale orders). The transaction ID is by default the Shopify order name
refundWeb order has been refunded
upsellUser has accepted a post-purchase upsell offer
note:

Transaction events may be delayed by 40 seconds to include any updates to order tags or status made by other apps after the order was created

Supported checkouts

Littledata sends checkout steps to Google Analytics automatically, to ensure you can report on checkout conversions out of the box.

Littledata supports checkout funnel event tracking for:

Checkout journey starts when a user clicks the checkout button. Here is the structure of these events and how they work.

Shopify checkout tracking

Custom parameters

The custom event parameters listed in this table are sent with every event. The user-scope parameters are sent when the customer logged in (typically step 2 of the checkout onwards).

Most of these are automatically created as custom dimensions during the Google Analytics 4 connection setup. For example, Google Ads can be targeted at new customers only by creating an audience where the custom dimension purchase_count_ld is 1.

ParameterDescriptionScope
user_idSpecial parameter, used for user identity. Only available when user data is enabledUser
lifetime_revenue_ldTotal of revenue from current and all previous purchases for that customer on ShopifyUser
purchase_count_ldCount of current and all previous purchases for that customerUser
last_transaction_date_ldDate of customer's last orderUser
shopify_customer_id_ldCustomer ID as used on ShopifyUser
littledata_client_idClient ID: the cookie identifier Google uses to group events by userUser
affiliationA coma-separated list of order tags. Untagged orders use ShopifyEvent
store_nameThe name of the Shopify store generating the event. Useful when you have multiple country stores feeding into one GA property.Event
app_name_ldThe app name that generated the order (fallback on app ID).Event

Amazon Marketplace as a sales channel

Littledata also provides support for customers who rely on Amazon Marketplace as a sales channel. Amazon is processing the order themselves instead of directing the user to the Shopify checkout and this can create issues with reconciling the transactions and tracking. A recent update brings more clarity when analyzing transaction sources and will help avoid confusion.

  1. Orders from Amazon are now displayed in GA reports as coming from "amazon.com/referral" instead of "direct"
  2. This will eliminate confusion about an increase in direct traffic share (% of transactions coming from direct) without any increase in direct traffic volume