How to integrate GA4 with Shopify, in short: create a GA4 property and web data stream in Google Analytics, install Shopify's free Google & YouTube app, and connect your Analytics property from the app's Overview page. That covers most stores. If you need full control of the events, you can instead add the GA4 code to Shopify as a custom pixel under Settings > Customer events. Whichever you choose, use only one.
It sounds straightforward until you try it. There are several installation methods, confusing options, and the eCommerce event tracking (especially GA4 Shopify checkout tracking) that most guides skip. Get it wrong and you'll be making business decisions on incomplete or double-counted data. This guide covers the installation options, which to choose, which events to track, and how to verify it all works. If you run Facebook or Instagram ads too, my Meta Pixel Shopify setup guide uses the same Customer events system.
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.
How to add GA4 to Shopify, method 1: a custom pixel
Shopify introduced Custom Pixels as the way to add your own third-party
tracking scripts. You create a custom pixel in your Shopify admin under
Settings > Customer events, paste your GA4 tracking code, and
Shopify runs it in a sandbox, separate from your theme. This is the modern answer to
"how do I add GA4 code to Shopify?": not in theme.liquid, but in a pixel.
Pros
- Built into Shopify: it's Shopify's own place for adding your own tracking code
- 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 customer privacy settings, so the pixel can wait for the visitor's cookie consent
- 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 — Google Tag Assistant can't see tags inside a custom pixel, and Tag Manager's preview mode may not work
- Not supported by either company: Shopify doesn't support the code you put in a custom pixel, and Google says running Google tags inside one isn't a supported set-up, so you're on your own if something breaks
How to set it up
- Remove any other GA4 tags first (the Google & YouTube app's Analytics connection, old code in
theme.liquid, other tracking apps) so events aren't counted twice - Go to Settings > Customer events in your Shopify admin
- Enter a name for the pixel, such as "Google Analytics 4", and click Add pixel
- In Customer privacy, set the Permission and Data sale options to match your cookie consent set-up
- Paste the GA4 code into the Code window: the Google tag with your Measurement ID (it starts with G-), then subscriptions to Shopify's customer events mapped to GA4 eCommerce events (example below)
- Click Save, then Connect pixel
Example: mapping Shopify events to GA4
Shopify's standard customer events line up neatly with GA4's recommended eCommerce events:
product_viewed to view_item, product_added_to_cart to
add_to_cart, checkout_started to begin_checkout and
checkout_completed to purchase. A simplified purchase mapping, after
the Google tag has loaded and gtag('config', 'G-XXXXXXX') has run:
analytics.subscribe('checkout_completed', (event) => {
const c = event.data.checkout;
gtag('event', 'purchase', {
transaction_id: c.order?.id,
value: c.totalPrice.amount,
currency: c.totalPrice.currencyCode,
items: c.lineItems.map((i) => ({
item_id: i.variant?.id,
item_name: i.title,
quantity: i.quantity
}))
});
});
Installation method 2: Google & YouTube app
Shopify's official Google & YouTube app is the Shopify GA4 app both Shopify and Google point merchants to. You connect your Google account, link your GA4 property, and the app handles the implementation, including the purchase event.
How to set it up
- In Google Analytics, create a GA4 property and a web data stream for your store, and note the Tag ID (it starts with G-)
- In Shopify, install the Google & YouTube sales channel from the Shopify App Store
- Open the app and click Connect Google account, signing in with the Google account that has access to your Analytics property (the app asks for this before anything else)
- On the app's Overview page, find the section for setting up Google Analytics 4 only and click Get started (you don't have to connect Google Merchant Center)
- Connect your Analytics property and click Confirm
- Make sure your online store isn't password-protected: Shopify notes that Google Analytics can't track events while the store is in private mode
Google also documents a manual route inside the same app (Settings > Google tags > Manage) for adding tags yourself, for example to send data to more than one Analytics property.
What the app sends to GA4, and what it doesn't
Google publishes the list of events the app sends. It's a solid set, but it isn't every GA4 eCommerce event:
- Sent:
page_view,view_item_list,view_item,search,add_to_cart,remove_from_cart,view_cart,begin_checkout,add_shipping_info,add_payment_infoandpurchase. Product events include the item ID, name, brand, category, variant, price and quantity, andpurchaseincludes the transaction ID, tax, shipping and coupon. - Not sent:
select_item(clicking a product in a list),view_promotionandselect_promotion,add_to_wishlist,sign_up,loginandrefund, so refunds never come off your GA4 revenue. There's nouser_idand no item-level discount, and you can't add your own events or parameters through the app. - Worth knowing: the purchase
valueis after discounts and leaves out shipping and tax, which are sent separately.
Pros
- Easiest setup — no code required, just connect your Google account
- Sends the main eCommerce events automatically, from product views to purchase (see the list above)
- Also manages Google Merchant Center product feed sync
- Free and officially supported by both Shopify and Google
Cons
- Fixed event set — you get the events the app provides and nothing else: no
select_item, promotion or refund events, no user ID, and no way to add custom events or parameters - No Google Tag Manager: Google says you can't set up Tag Manager through the app
- 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
Alternative method: the Loves Data setup
If you want more control over what goes to GA4 than the Google & YouTube app allows, but don't want to pay for a tracking app or write a pixel from scratch, look at the guide from Loves Data, a Google Analytics training company. It's an alternative to the app built on method 1: a ready-made Shopify custom pixel passes your store's eCommerce events into Google Tag Manager, and a pre-configured Tag Manager container sends them on to GA4. You request copies of both through forms on their site.
Because the events run through your own Tag Manager container, you decide which events and parameters are sent, and you can add ones the app leaves out. The trade-off is the same as any custom pixel: Google doesn't support Google tags running inside one, and Tag Manager's preview mode may not work, so test carefully. For the full step-by-step instructions, see Loves Data's guide to setting up Google Analytics 4 on Shopify.
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, which often rises with features or order volume: check each app's current pricing on its App Store listing
- 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.
Hard-coded snippets are also the ones most often left behind when a theme changes or a developer moves on, which is part of the hidden cost of cheap Shopify themes: you inherit whatever the last person pasted in.
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
- No checkout tracking — theme code doesn't run on Shopify's checkout, Thank you or Order status pages, and the old "Additional scripts" box has been replaced, so purchase events still need a custom pixel or the Google & YouTube app (see the checkout section below)
- 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 main eCommerce events, though not all of them (see the list above).
- Want more control over the eCommerce data without paying for an app? Use the Loves Data setup, a ready-made custom pixel and Tag Manager container, as a starting point.
- Comfortable writing JavaScript? Build your own Shopify Custom Pixel. It gives you Shopify-native tracking that sends exactly what you choose.
- 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, plus a custom pixel for checkout, which theme code can't reach.
Whatever method you choose, only use ONE. Running multiple GA4 implementations simultaneously is the most common cause of duplicate event data and inflated metrics.
GA4 Shopify checkout tracking
Checkout is where most GA4 set-ups on Shopify go wrong, because it doesn't behave like the rest of the store:
- Theme code doesn't run at checkout. A GA4 snippet in
theme.liquidsees your product and cart pages but not checkout, so on its own it can't recordbegin_checkoutorpurchase. - "Additional scripts" are gone. Shopify's Thank you and Order status pages moved to the new checkout system. The cut-off was 28 August 2025 for Shopify Plus stores and 26 August 2026 for everyone else, after which old scripts on those pages stopped running. Purchase tracking that lived in the old Additional scripts box no longer runs.
- Customer events are the replacement. Shopify's standard events include
checkout_started,checkout_contact_info_submitted,checkout_shipping_info_submitted,payment_info_submittedandcheckout_completed, available to the Google & YouTube app and to custom pixels.
So for reliable checkout data, either let the Google & YouTube app send it or subscribe to those events in a custom pixel, as in the example above. If your purchases dropped off in GA4 around the upgrade, this is almost certainly why.
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
First turn on debug mode: Google suggests opening your store through Tag Assistant
(tagassistant.google.com), or adding 'debug_mode': true to your gtag('config', ...) call. With a
custom pixel, the debug_mode parameter is the dependable option, because Tag Assistant can't see inside the pixel's
sandbox. Then, in your GA4 property, go to Admin > Data display > DebugView 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. Remove debug_mode when you've finished.
GA4 realtime report
Go to Reports > Realtime in GA4. Open your store in another browser tab and navigate around. You should see your activity appear shortly, though Google describes Realtime as best effort. Check that eCommerce events (add_to_cart, begin_checkout, purchase) appear when you perform those actions.
Google Tag Assistant
Google Tag Assistant (tagassistant.google.com, with the Tag Assistant Companion Chrome extension) shows you which Google tags fired on a page, in what order, and with what data. It can't see tags inside a Shopify custom pixel, so for those use Shopify's Pixel Helper extension to check events are reaching the pixel without errors.
Test a real purchase
The only way to truly verify purchase tracking is to complete an order through checkout. Use Shopify's Bogus Gateway for testing: in Settings > Payments, deactivate your card provider (including Shopify Payments), choose a new provider, search for "Bogus", select Test payment gateway and click Activate. Place an order, then check GA4 for the purchase event with the correct order value, transaction ID, and product details. Switch your real payment provider back on afterwards.
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 — theme code and old Additional scripts don't run at checkout. Make sure purchases come from the Google & YouTube app or a custom pixel subscribed to
checkout_completed. - 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.
- Odd or inflated page views — in a custom pixel, GA4's automatic page views can pick up the sandbox's own address. Shopify suggests turning automatic page tracking off and sending your own
page_viewfrom thepage_viewedevent. If your theme changes the URL without a full page load, GA4's enhanced measurement can also count those changes as extra page views. - 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.
Tracking scripts also cost page speed. If the store felt slower after adding a tracking app, see how Shopify apps slow your store and how to fix it.
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
Once the numbers are right, use them. My guide to fixing a low Shopify conversion rate shows what to look for, and if you run Facebook or Instagram ads, pair GA4 with a properly set up Meta Pixel. If you'd rather hand the whole thing over, I set up and fix GA4 and Meta Pixel tracking on Shopify; get in touch for a quote. GA4 shows what visitors do on your site; for how they find it, see why your Shopify store isn't ranking on Google.
GA4 and Shopify: frequently asked questions
How do I integrate GA4 with Shopify?
Create a GA4 property and web data stream, install the Google & YouTube app in Shopify, and on its Overview page choose the Google Analytics 4 set-up, click Get started, connect your property and confirm.
How do I add GA4 code to Shopify?
Add it as a custom pixel: Settings > Customer events, name the pixel, click Add pixel, paste the Google tag with your G- Measurement ID plus code that maps Shopify's customer events to GA4 events, then Save and Connect pixel. Code pasted into theme.liquid won't see checkout.
Does GA4 track the Shopify checkout?
Yes, if it's set up through the Google & YouTube app or a custom pixel subscribed to Shopify's checkout events. Theme code and the old Additional scripts box don't run at checkout, so they can't record purchases.
What is the best Shopify GA4 app?
For a quick start, Shopify's free Google & YouTube app, which Shopify and Google both recommend. Be aware it doesn't send every GA4 eCommerce event: there's no select_item, promotion or refund tracking, no user ID, and you can't add your own events. For more control without a paid app, use a custom pixel, such as the Loves Data setup. Paid tracking apps add server-side tracking and more platforms if you need them.
Why are my GA4 purchases duplicated?
Usually two implementations are running, such as the Google & YouTube app and a custom pixel or old theme code. Keep one and remove the rest.
Why did my GA4 purchase tracking stop working?
If it relied on Additional scripts on the Thank you or Order status pages, it stopped when those pages moved to the new checkout system (the cut-off for non-Plus stores was 26 August 2026). Move purchase tracking to the app or a custom pixel.
