Setting up Google Analytics 4 (GA4) on a Shopify store sounds straightforward — until you actually try to do it. There are multiple installation methods, confusing configuration options, and the critical eCommerce event tracking that most guides skip over. Get it wrong and you'll be making business decisions based on incomplete or inaccurate data.
This guide covers everything: the installation options, which one to choose, which eCommerce events to track, and how to verify it's all working correctly.
What GA4 Tracks and Why It Matters
GA4 is event-based, meaning every interaction is tracked as an event rather than a pageview. For a Shopify store, the key events you want to capture are:
- page_view — every page a visitor loads
- view_item — when a customer views a product page
- add_to_cart — when a product is added to the cart
- begin_checkout — when a customer starts the checkout process
- add_payment_info — when payment details are entered
- add_shipping_info — when shipping information is provided
- purchase — when an order is completed (the most important event)
- view_item_list — when a customer views a collection page
- search — when a customer uses site search
Without these eCommerce events, GA4 only shows you pageviews and basic engagement. You won't know your add-to-cart rate, checkout abandonment rate, or revenue per session — the metrics that actually matter for growing an eCommerce business.
Installation Method 1: Shopify's Custom Pixel
Shopify introduced Custom Pixels as the recommended way to add third-party tracking scripts. You create a custom pixel in your Shopify admin under Settings > Customer events, paste your GA4 tracking code, and Shopify handles the execution in a sandboxed environment.
Pros
- Shopify-recommended approach — designed for their platform
- Runs in a sandboxed iframe, which isolates the script from your theme and improves security
- Access to Shopify's customer event APIs — you can subscribe to checkout events, page views, and product interactions
- Works with Shopify's consent management for GDPR compliance
- No theme code editing required
Cons
- The sandboxed environment means the GA4 script runs in an iframe, which can affect cookie setting and user identification across sessions
- Requires JavaScript knowledge to set up eCommerce event tracking properly
- Limited debugging — the sandbox makes it harder to test with GA4 DebugView compared to direct implementation
How to Set It Up
- Go to Settings > Customer events in your Shopify admin
- Click Add custom pixel and name it "Google Analytics 4"
- Add the GA4 configuration code with your Measurement ID (starts with G-)
- Subscribe to Shopify's customer events and map them to GA4 eCommerce events
- Set the pixel's permission to "Not required" or configure it with your consent management
- Click Save and then Connect
Installation Method 2: Google & YouTube App
Shopify's official Google & YouTube app (formerly the Google channel) provides built-in GA4 integration. You connect your Google account, link your GA4 property, and the app handles the implementation.
Pros
- Easiest setup — no code required, just connect your Google account
- Handles basic eCommerce events automatically
- Also manages Google Merchant Center product feed sync
- Free and officially supported by both Shopify and Google
Cons
- Limited event customisation — you get the events the app provides, with little ability to add custom events or parameters
- Can conflict with other GA4 implementations — if you also have a custom pixel or theme code, you may get duplicate events
- Data discrepancies — some merchants report differences between the app's tracking and direct GA4 implementations, particularly around checkout events
- The app adds its own JavaScript to your storefront, which affects page performance
Installation Method 3: Third-Party Tracking Apps
Several Shopify apps specialise in analytics tracking implementation. The most established options include Elevar, Littledata, and Analyzify. These apps offer advanced tracking features beyond what native solutions provide.
Pros
- Server-side tracking — some offer server-side GA4 integration via the Measurement Protocol, which is more reliable than client-side JavaScript and not blocked by ad blockers
- Enhanced eCommerce events — more detailed event data including product list positions, variant information, and custom dimensions
- Multi-platform support — many also handle Facebook CAPI, TikTok, Pinterest, and other platforms from one integration
- Data layer management — proper dataLayer implementation for Google Tag Manager
Cons
- Monthly cost — typically £50–200+ per month depending on features and order volume
- Complexity — more features means more configuration and more things that can go wrong
- Another app on your store — which adds to the overall script load
Installation Method 4: Direct Theme Code
The most hands-on approach is adding the GA4 gtag.js snippet directly
into your theme's layout/theme.liquid file and manually implementing
eCommerce event tracking through the Shopify Liquid and JavaScript APIs.
Pros
- Full control — you decide exactly what fires, when, and with what data
- No app dependency — no monthly costs, no app updates breaking things
- Performance — you can optimise the implementation for minimal page load impact
- Works with Google Tag Manager (GTM) if you prefer managing tags through GTM
Cons
- Requires developer skills — Liquid template knowledge, JavaScript, and GA4 event specification understanding
- Checkout tracking is limited — Shopify restricts theme code access on checkout pages (unless you're on Shopify Plus), so purchase events need to be tracked via the order status page or additional scripts
- Maintenance burden — you're responsible for keeping the implementation up to date when GA4 or Shopify change their APIs
Which Method Should You Choose?
Here's the practical recommendation based on your situation:
- Just need basic tracking quickly? Use the Google & YouTube app. It's free, it works, and it covers the fundamentals.
- Want proper eCommerce tracking without paying for an app? Use Shopify's Custom Pixel. It requires some JavaScript knowledge but gives you solid, Shopify-native tracking.
- Running significant ad spend and need accurate attribution? Consider a third-party app like Elevar for server-side tracking and cross-platform support.
- Want maximum control and have developer resources? Go direct theme code with Google Tag Manager for the most flexible setup.
Whatever method you choose, only use ONE. Running multiple GA4 implementations simultaneously is the most common cause of duplicate event data and inflated metrics.
Verifying Your GA4 Implementation
Setting up GA4 is only half the job. You need to verify that events are firing correctly and data is accurate. Here's how:
GA4 DebugView
In your GA4 property, go to Admin > DebugView. Install the Google Analytics Debugger Chrome extension, enable it, and browse your store. You'll see events appearing in real-time, letting you verify each event fires at the right moment with the correct parameters.
GA4 Realtime Report
Go to Reports > Realtime in GA4. Open your store in another browser tab and navigate around. You should see your activity appearing within seconds. Check that eCommerce events (add_to_cart, begin_checkout, purchase) appear when you perform those actions.
Google Tag Assistant
The Google Tag Assistant Chrome extension shows you which Google tags are firing on any page. It will flag errors, missing events, and configuration issues.
Test a Real Purchase
The only way to truly verify purchase tracking is to complete a real order. Use Shopify's Bogus Gateway for testing (Settings > Payments > Bogus Gateway). Place an order, then check GA4 for the purchase event with the correct order value, transaction ID, and product details.
Common GA4 + Shopify Problems
- Duplicate events — usually caused by having multiple GA4 implementations active. Check for the Google & YouTube app, custom pixels, and theme code all running simultaneously.
- Missing purchase events — checkout pages have limited script access. If purchase events aren't firing, check your order status page scripts and ensure the implementation uses Shopify's customer event APIs.
- Currency mismatches — if you sell in multiple currencies, ensure the currency parameter is passed correctly with each eCommerce event. GA4 needs this to calculate revenue accurately.
- Inflated page views — Shopify's storefront can fire additional page views during AJAX navigation. Ensure your implementation handles single-page app behaviour correctly.
- Missing user data — GA4's consent mode affects what data is collected. If you're using a cookie consent banner, ensure GA4 is configured for consent mode v2 to maintain measurement while respecting user privacy.
After Setup: What to Look At
Once GA4 is working correctly, focus on these reports:
- Monetisation > Ecommerce purchases — your revenue, transactions, and top-selling products
- Acquisition > Traffic acquisition — where your visitors come from and which channels drive revenue
- Engagement > Pages and screens — which pages get the most views and engagement
- Explore > Funnel exploration — build a custom funnel from product view to purchase to see exactly where customers drop off