Key Takeaways
- GA4 is Google's latest analytics platform, using event-based tracking of clicks, scrolls, purchases, and engagement instead of just pageviews.
- For Shopify stores, GA4 delivers better shopping-behavior insights, cross-device tracking, accurate attribution, and built-in Google Ads integration.
- Start by copying your GA4 Measurement ID (G-XXXXXXXXXX) from Admin, Data Streams, Web in your Google Analytics account.
- The easiest setup is connecting GA4 through Shopify's free Google & YouTube app, which adds the Google tag to your store for you.
- For more control, you can add the gtag.js tag to your theme.liquid file, but theme code doesn't run on checkout, so purchase tracking needs the app or a custom pixel.
If you run a Shopify store, tracking your visitors’ behavior is essential for understanding what’s working—and what isn’t. Google Analytics 4 (GA4) is the latest version of Google’s powerful analytics platform, offering improved tracking, event-based data collection, and deeper insights into customer journeys.
In this guide, we’ll walk you through how to add GA4 to your Shopify theme so you can start collecting valuable data right away.
Why Use GA4 for Your Shopify Store?
Google Analytics 4 is built for today’s ecommerce environment. Unlike the old version, GA4 doesn’t just track pageviews—it focuses on events like clicks, scrolls, purchases, and user engagement. This means you’ll get:
- Better insights into customer shopping behavior
- Cross-device and cross-platform tracking
- More accurate attribution models
- Built-in integration with Google Ads
Now, let’s look at how to add GA4 to Shopify.
Step 1: Get Your GA4 Measurement ID
- Go to your Google Analytics account.
- Click Admin > Data Streams > Web.
- Select your store’s data stream.
- Copy your Measurement ID, which looks like: G-XXXXXXXXXX.
Step 2: Add GA4 to Shopify
There are two main ways to integrate GA4 with your Shopify store:
Option 1: Using the Google & YouTube App (Preferred)
- In your Shopify admin, install the free Google & YouTube app from the Shopify App Store.
- Connect the Google account that has access to your GA4 property.
- Follow the app’s Google tag setup and select your GA4 property (the one with your Measurement ID).
- Save changes.
Option 2: Manually Adding the Code to Your Theme
If you want more control, you can paste the tracking code directly into your theme. Keep in mind that theme code only runs on your storefront pages, not on Shopify’s checkout, so checkout and purchase events still need the Google & YouTube app or a custom pixel (Settings > Customer events).
- In Shopify, go to Online Store > Themes.
- Click the … (more actions) menu > Edit code next to your theme.
- Under Layout, open theme.liquid.
- Just before the closing </head> tag, paste your GA4 global site tag:
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
</script>
- Replace G-XXXXXXXXXX with your actual Measurement ID.
- Save your changes.
Step 3: Verify GA4 Tracking
Once you’ve added the tracking code:
- Open your store in a new browser tab.
- Go to Google Analytics > Realtime Report.
- Refresh your store page. If installed correctly, you’ll see your visit appear in real-time.
Why Work With eSEOspace for Shopify Success?
While setting up GA4 is an important step, maximizing its value requires strategy. That’s where eSEOspace comes in. As a top-level software company, eSEOspace specializes in Shopify website development, Shopify SEO, and Shopify Google Ads management. By combining cutting-edge design with data-driven marketing, our team helps Shopify businesses not only track their performance but also scale their growth with proven digital strategies.
Wrapping Up
Adding GA4 to your Shopify theme only takes a few minutes, but the insights it provides can completely transform how you understand your customers. From traffic sources to purchase behavior, GA4 helps you make smarter marketing decisions and boost sales.
If you haven’t set it up yet, now is the perfect time.
Get a FREE Audit
We'll perform a comprehensive SEO, AEO, GEO & CRO audit of your website — completely free — and show you exactly how to outrank your competitors.
Don't have a site yet? Get in touch →
Frequently Asked Questions
What is GA4 and why should I use it for my Shopify store?
GA4 is Google Analytics 4, the latest version of Google's analytics platform. Unlike the old version that tracked pageviews, GA4 focuses on events like clicks, scrolls, purchases, and engagement. For Shopify stores, this means better shopping-behavior insights, cross-device tracking, more accurate attribution, and built-in Google Ads integration.
Where do I find my GA4 Measurement ID?
Log into your Google Analytics account and click Admin, then Data Streams, then Web. Select your store's data stream and copy the Measurement ID, which looks like G-XXXXXXXXXX. You'll paste this ID into Shopify or your theme code to connect GA4 and start collecting visitor data from your store.
What is the easiest way to add GA4 to Shopify?
The preferred method uses Shopify's free Google & YouTube app. Install it from your Shopify admin, connect your Google account, and follow its Google tag setup to select your GA4 property. This approach avoids editing code and lets Shopify handle the integration, including checkout events, making it the simplest option for most store owners.
How do I manually add the GA4 code to my Shopify theme?
Go to Online Store, then Themes, click the … menu next to your theme, then Edit code. Under Layout, open theme.liquid and paste your GA4 global site tag (gtag.js) just before the closing head tag. Replace G-XXXXXXXXXX with your actual Measurement ID and save. This method gives you more control, but it doesn't run on checkout, so add a custom pixel for purchase events.
How do I verify that GA4 tracking is working?
After adding your tracking code, open your store in a new browser tab. In Google Analytics, go to the Realtime report, then refresh your store page. If GA4 is installed correctly, you'll see your own visit appear in real-time, confirming that data is being collected and your setup is functioning properly.
Put this into action with eSEOspace
We help businesses grow with website development that actually performs. Explore the services behind this guide:
Book a free strategy call →