How to Add Google Analytics 4 to Shopify
Adding Google Analytics 4 to your Shopify store is a fundamental step toward understanding how customers find and interact with your products. While Shopify's built-in analytics are useful, GA4 provides a much deeper view of your marketing performance and the complete customer journey. This guide will walk you through a couple of methods for connecting GA4 to Shopify, from the simple, built-in option to a more robust manual setup.
Why Connect GA4 to Your Shopify Store?
Before jumping into the setup, it's worth understanding what you gain by making this connection. Shopify Analytics gives you a good overview of sales and store performance, but GA4 is built to analyze the entire user path, from the first ad they see to their final purchase.
Connecting GA4 helps you:
Understand the Full Customer Journey: See which marketing channels (like Google Ads, Facebook, email newsletters) are actually driving traffic and sales, not just one or the other.
Analyze On-Site Behavior: Discover which pages and products are most popular, how long users stay on your site, and where they tend to leave.
Optimize Your A-to-Z Sales Funnel: Identify weak points where customers drop off, such as during the add-to-cart process or in the middle of checkout.
Track E-commerce Events: Measure specific actions like
add_to_cart,begin_checkout, andpurchaseto get a detailed picture of your conversion process. This goes far beyond simple page views.Build Custom Reports: Create reports tailored to your specific business goals, mixing and matching dimensions and metrics that Shopify’s dashboard can’t.
First, Create Your GA4 Property
You can't add GA4 to Shopify if you don’t have a GA4 property yet. If you already have one and just need your Measurement ID, you can skip this section. If not, follow these quick steps.
1. Create a Google Analytics Account
If you don’t have a Google Analytics account at all, start here. If you do, you can just add a new property to your existing account.
Go to the Google Analytics website and log in with your Google account.
Click on the Admin gear icon in the bottom-left corner.
In the Account column, click Create Account. Give your account a name (like your company name) and configure the data-sharing settings. Click Next.
2. Create a GA4 Property
Next, you’ll create the property for your Shopify store.
In the Property column, enter your store’s name as the Property name.
Select your reporting time zone and currency. Click Next.
Answer the optional questions about your business and click Create.
3. Create a Data Stream
Your "Data Stream" is the source of data for your property, which in this case is your Shopify website.
You'll be prompted to choose a platform. Select Web.
Enter your Shopify store’s URL (e.g.,
yourstore.myshopify.com) and give the stream a name (e.g., "Shopify Store").Make sure "Enhanced measurement" is turned on. This automatically tracks things like page views, scrolls, and outbound clicks.
Click Create stream.
Once you’ve created the stream, a page will appear called "Web stream details." Here you will find your Measurement ID, which looks like G-XXXXXXXXXX. Copy this ID - you’ll need it for the next steps.
Method 1: Connect GA4 Using Shopify’s Native Integration
Shopify provides a simple way to add Google Analytics directly from your admin dashboard. This is the easiest and fastest method, ideal for store owners who want a basic setup without touching any code.
Note: This method requires that you have the Google & YouTube app installed and set up in your Shopify store.
Step-by-Step Instructions
From your Shopify admin, go to Online Store > Preferences.
Scroll down to the Google Analytics section.
Click on Manage pixel here. This will take you to the settings within the Google & YouTube app.
In the section labeled "Your Google Analytics property," click the Connect button.
You'll be prompted to sign into the Google account associated with your GA4 property.
Select your GA4 property from the list and click Connect.
That's it! Shopify will now automatically add the necessary GA4 tracking code to your store's pages. It’s simple, but keep in mind that this native integration might not capture every e-commerce event with the detail that a manual setup could. It's a great starting point, though.
Method 2: Manually Add the GA4 Tag to Your Theme Code
For more control and to ensure your GA4 tag fires correctly across your entire site, you can add the code snippet directly into your theme’s code. This method bypasses Shopify’s apps and places the tracking tag directly where it needs to be.
Heads up: Before editing any code, always create a backup of your theme. From your Shopify admin, go to Online Store > Themes, find your current theme, click the three-dots icon, and select Duplicate. This creates a safety copy in case anything goes wrong.
Step-by-Step Instructions
From your Google Analytics account, go to Admin > Data Streams and click on your web stream to open the details.
Under "Google tag", click on View tag instructions.
A card will appear with installation instructions. Select the Install manually tab. You will see a JavaScript snippet. Click the copy icon to copy the entire code block. It will look something like this:
`
Now, go back to your Shopify admin dashboard.
Go to Online Store > Themes. Find your theme, click the three-dots icon, and select Edit code.
In the theme editor, under the Layout folder, find the file named
theme.liquidand click to open it.Scroll down or use Ctrl+F (or Cmd+F) to find the closing
</head>tag. It's usually located near the top of the file.Paste the entire Google Tag code you copied from GA4 on a new line right before the closing
</head>tag.Click Save.
Manually placing the tag here gives you peace of mind that it will load on every page of your store, from the homepage to product pages.
Important: Enabling Shopify E-commerce Tracking
Installing the base GA4 tag will track page views and other basic engagement, but it won't track crucial commerce activity like adding items to a cart or completing a purchase. To get this data into GA4, you need to enable e-commerce event tracking.
For merchants on standard Shopify plans, you have a straightforward, but somewhat limited, option:
Enable Tracking via Order Status Page Scripts
Shopify allows you to add extra tracking scripts that run only after a successful purchase. This is where you can tell Google Analytics about a completed transaction.
In Shopify Admin, go to Settings > Checkout.
Scroll all the way down to the Order status page section.
In the Additional scripts text box, you'll need to add a special version of your Google tag that includes code to track purchase events. The full details are quite technical, requiring you to insert Shopify Liquid objects for things like transaction ID, value, and products purchased. Shopify provides detailed guides in their help center for this specific code.
If you're a Shopify Plus user, you have access to the checkout.liquid file, which allows for a much more comprehensive and accurate tracking setup via Google Tag Manager (GTM). Setting up GTM is beyond this article, but it's the professional standard for robust e-commerce analytics.
How to Verify Your GA4 Installation is Working
After inserting the code, the final step is to make sure it's working properly. The easiest way to do this is with GA4's Realtime report.
Open your Shopify store in a new browser window or tab. Click around to a few different pages.
In your Google Analytics account, navigate to Reports > Realtime.
Within a minute or two, you should see yourself as an active user on the map and in the "Users in Last 30 Minutes" card.
If you see your activity show up, congratulations! Your GA4 tag has been successfully added to your Shopify store, and you'll now start collecting valuable data about your visitors.
Final Thoughts
Connecting Shopify to Google Analytics 4 is no longer a nice-to-have, it's an essential diagnostic tool for growth. Whether you use Shopify’s simple integration or add the code manually, getting it set up opens the door to understanding exactly how your marketing efforts translate into sales.
Once you have the data flowing, the next challenge is turning it into clear, actionable insights without getting overwhelmed. At Graphed, we simplify this entire process. We built Graphed to connect to your Shopify and Google Analytics accounts in seconds, letting you create dashboards and get insights just by asking questions. Instead of wrestling with GA4 reports, you can just type, "Show me which campaigns are driving the most revenue," and see a live chart instantly. We automate the tiresome analysis so you can get back to growing your business.