Blog
How to Add Google Analytics 4 (GA4) to Your Shopify Theme

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 Shopify Admin (Preferred)
- In your Shopify admin, go to Settings > Preferences.
- Scroll to the Google Analytics section.
- Paste your GA4 Measurement ID.
- Save changes.

Option 2: Manually Adding the Code to Your Theme
If you want more control—or Shopify doesn’t automatically recognize GA4—you can paste the tracking code directly into your theme.
- In Shopify, go to Online Store > Themes.
- Click Actions > Edit Code.
- 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 →
Make Your Website Competitive.
Leverage our expertise in Website Design + SEO Marketing, and spend your time doing what you love to do!






