How it works: Shopify to Google Analytics 4

Updated on 2022-04-22
note:

If you're using Universal Analytics, from before 2021, you need How It Works for Universal Analytics

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 LittledataLayer snippet is included in theme.liquid).

  • LittledataLayer window-scope Javascript object is added on all pages, which you can also use with Google Tag Manager (GTM).
  • A minified tracking script, hosted on a content delivery network (CDN), is loaded in the <head> of each page
  • 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

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

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

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 an web order (excluding iOS, Android, POS and draft orders). The transaction ID is by default the Shopify order name
refundWeb order has been refunded
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

User properties

With all the ecommerce events from the checkout onwards we sent extra user properties to help you build audiences and analyze behavior. You will need to create user-scope custom dimensions to use these in reporting.

User propertyDescription
lifetime_revenue_littledataTotal of all previous purchases for that customer on Shopify
purchase_count_littledataCount of all previous purchases for that customer
last_transaction_date_littledataDate of customer's previous order
shopify_customer_id_littledataCustomer ID as used on Shopify
payment_gateway_littledataThe gateway used to process the last order's payment
littledata_client_idClient ID: the cookie identifier Google uses to group events by user

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