← All Articles
Analytics10 min read·16 April 2026

GA4 Setup for Shopify Stores in 2026 - The Complete Guide That Actually Works

KR

Khemraj Rikhari

Digital Marketing Manager & AI Systems Builder · Dubai, UAE

Hire Me

Shopify's native GA4 integration works in the sense that it sends data to GA4. What it doesn't do is send complete, reliable eCommerce data. Purchase events miss line-item detail. Checkout funnel steps are inconsistently tracked. And the events from Shopify's protected checkout flow don't reach your GTM container at all. Here's the setup that actually gives you accurate data.

Step 1: Create and Configure Your GA4 Property

Go to analytics.google.com, create a new GA4 property, add a Web stream for your Shopify store. Your Measurement ID will look like G-XXXXXXXXXX - save this. In the stream settings, go to Enhanced Measurement and enable Scrolls, Outbound Clicks, and Site Search if you have search functionality. Disable Form Interactions for now - it can fire on Shopify's liquid-rendered forms in ways that pollute your data.

In GA4 Admin, go to Data Settings → Data Retention and change from the default 2 months to 14 months. This is a settings change that has no downside and prevents losing comparative data mid-year.

Step 2: Install Google Tag Manager on Shopify

Don't add your GA4 tag directly to Shopify - manage it through GTM. This gives you flexibility to add events without editing theme code every time.

In your Shopify Admin, go to Online Store → Themes → Actions → Edit Code. Open theme.liquid and add your GTM container snippet immediately after the opening <head> tag (the script version) and immediately after the opening <body> tag (the noscript version). Save both changes.

In GTM, create a new GA4 Configuration tag with your Measurement ID. Fire it on All Pages. This is your base tag that loads GA4 on every page.

Step 3: eCommerce Event Tracking via GTM

This is where most guides stop being useful. Here are the events that matter and how to set them up:

view_item on product pages: Create a GTM trigger for Page View on URLs containing /products/. Fire a GA4 event tag with the event name "view_item" and use Shopify's dataLayer to populate the items array with product ID, name, price, and category. Shopify pushes some of this to the dataLayer automatically on product pages.

add_to_cart: Create a Custom Event trigger listening for "add-to-cart" (Shopify pushes this to the dataLayer when the button is clicked on most themes). Fire an "add_to_cart" GA4 event with items populated from the dataLayer.

begin_checkout: Trigger on click of checkout button or on URL containing /checkout. The items here should include the full cart contents - you may need a Custom JavaScript variable to read cart data from Shopify's cart.js endpoint.

purchase: This is the critical one. It cannot be done via standard GTM on Shopify because the thank-you page is inside Shopify's protected checkout domain. Use Shopify Pixels for this (Step 4).

Step 4: Shopify Pixels for Checkout Events (The 2026 Method)

Shopify Customer Events (Pixels API) is the correct 2026 method for tracking events that happen inside Shopify's checkout flow. Your GTM container cannot access these pages - pixels run in a sandboxed environment that Shopify controls.

Go to Shopify Admin → Settings → Customer Events → Add Custom Pixel. Create a new pixel and use the Shopify Pixels API to fire GA4 events directly via gtag within the sandbox. The key events to fire here:

  • purchase - fire when the checkout_completed event fires, include transaction ID, revenue, shipping, tax, and the items array
  • begin_checkout - backup in case GTM doesn't catch it on all checkout paths
  • add_payment_info - fires when payment details are entered in checkout

In the pixel code, use analytics.subscribe('checkout_completed', (event) => { ... }) to access the order data that Shopify passes to the event. The event.data.checkout object contains everything you need for the purchase event including line items, totals, and the order token.

Step 5: Link GA4 to Your Other Tools

Google Search Console: In GA4 Admin → Property Settings → Search Console links, connect your GSC property. This brings keyword data and click/impression data into GA4 for organic traffic analysis. This is one of the most valuable integrations for Shopify SEO work.

Google Ads: Link in GA4 Admin → Google Ads links. Import your GA4 purchase events as conversions in Google Ads for accurate Shopping and Search campaign optimisation.

Google Merchant Center: If you have GMC set up (which you should for free Shopping listings), link it to GA4 for cross-channel visibility.

Step 6: Verify Everything Before Trusting the Data

Use GA4 DebugView (found in the Admin panel) while testing. Go through a purchase on your store in test mode and watch events fire in real time. Check that:

  • purchase event fires exactly once per transaction
  • Revenue matches the actual order total
  • Transaction ID is unique (prevents duplicate counting)
  • Items array includes all purchased products with correct IDs and prices

Wait 48 hours after going live, then check the Monetization → Ecommerce Purchases report. If revenue there matches your Shopify revenue for the same period, your tracking is accurate. If there's a gap, you have double-counting or missing events - debug before making any decisions based on the data.

Work with me

Need help with Analytics?

I'm Khemraj Rikhari - based in Dubai, open to consulting and full-time roles across AI automation, Shopify growth, and digital marketing.