How to Add Google Analytics to Shopify Website
Getting a handle on your Shopify store's traffic is crucial for growth, and while Shopify's built-in analytics are useful, Google Analytics offers a much deeper look into how your customers behave. Connecting it gives you access to powerful insights about your audience, their journey on your site, and which marketing channels are actually driving sales. This guide will walk you through exactly how to connect Google Analytics 4 to your Shopify store, step-by-step, so you can start making more informed decisions.
Why Connect Google Analytics to Shopify?
You might be wondering, "Doesn't Shopify already show me my visitors, sales, and conversion rates?" Yes, it does, and that data is great for a quick overview. But Google Analytics answers a completely different set of questions. It's less about what happened (a sale) and more about the how and why behind it.
Think of it this way:
Shopify Analytics tells you: You got 10 sales from 500 visitors today.
Google Analytics tells you: Those 500 visitors came from three specific Facebook ads and a blog post you wrote last month. The visitors from the blog post viewed, on average, five pages before buying, while the Facebook traffic only viewed two. Most of your buyers were women aged 25-34 browsing on their iPhones in California.
Connecting GA4 to Shopify unlocks a goldmine of data that helps you understand the complete customer journey:
Detailed Audience Insights: Learn about your users' demographics (age, gender), location, interests, and the technology they use to browse your store.
Channel Performance: See exactly where your traffic comes from - Organic Search, Social Media, Email, Paid Ads, etc. - and which channels deliver the most valuable, highest-converting customers.
Enhanced Ecommerce Tracking: Automatically track key shopping behaviors like viewing a product, adding an item to the cart, starting the checkout process, and completing a purchase. This allows you to spot exactly where users are dropping off in the buying process.
User Behavior Flow: See the actual paths people take through your website. What pages do they land on first? Where do they go next? Which pages cause them to leave? This helps you identify and fix friction points on your site.
By using both platforms together, you get a full 360-degree view of your business: Shopify handles the transactions, and Google Analytics explains the customer behavior that leads to those transactions.
Before You Start: Create a Google Analytics 4 Property
Before you can connect anything to Shopify, you need to have a Google Analytics 4 property set up. If you're still using an old Universal Analytics property (its Tracking ID starts with "UA-"), you'll need to create a new GA4 property. Google is fully focused on GA4, and it's built for modern e-commerce tracking.
Here’s how to create one from scratch:
Step 1: Go to the Google Analytics Admin Panel
Sign in to your Google Analytics account. If you don't have one, you can create one with your Google account. Click the Admin gear icon in the bottom-left corner.
Step 2: Create a New Property
In the "Property" column, click the blue + Create Property button. If you're creating a brand new account, it will guide you through this same process.
Step 3: Enter Your Property Details
First, you'll be asked for basic property information:
Property name: Give your property a clear name, like "[Your Store Name] GA4 Property".
Reporting time zone: Select your store's primary time zone.
Currency: Choose the currency you use in your Shopify store.
Click Next and fill out the brief business information questions. This helps Google tailor your dashboard experience.
Step 4: Set Up a Data Stream
Now you need to tell Google where to collect data from. Since you're tracking a website, choose Web as your platform.
Next, you’ll be asked for your website details:
Website URL: Enter your Shopify store's URL (e.g.,
your-store-name.myshopify.comor your custom domain likewww.yourstore.com).Stream name: Give it a descriptive name, like "[Your Store Name] Web Stream".
Make sure "Enhanced measurement" is turned on. This feature automatically tracks important interactions like page views, scrolls, and outbound clicks without any extra coding. Click Create stream.
Step 5: Copy Your Measurement ID
After creating the stream, you'll see a "Web stream details" page. In the top right, you'll find your Measurement ID. It will look something like G-XXXXXXXXXX.
This ID is the key. It’s the unique identifier that tells Google, "all the data associated with this ID belongs to my online store." Copy this ID and keep it handy - you’ll need it in the next section.
Method 1: The Easy Way (Using Shopify’s Built-in Integration)
For nearly everyone, this is the best and most reliable method. Shopify has a native integration that makes connecting GA4 incredibly simple. It not only adds the tracking code but also automatically sets up enhanced e-commerce event tracking for you.
Here’s what to do:
Log in to your Shopify Admin dashboard.
On the left-hand navigation menu, under "Sales channels," click on Online Store, and then select Preferences.
Scroll down until you see the Google Analytics section.
In the provided field, paste the Measurement ID (e.g., G-XXXXXXXXXX) that you copied from your GA4 property.
Click the Save button in the top right corner.
That's it! Shopify will now automatically add the necessary GA4 tracking script (known as gtag.js) to every page of your store, including your checkout pages. Even better, this integration passes critical e-commerce data to Google Analytics, so it will track events like view_item, add_to_cart, and purchase right out of the box.
Method 2: Advanced Tracking by Manually Adding the GA4 Tag
This method involves editing your theme’s code. You should only use this method if you have a specific custom tracking requirement and are comfortable editing code. For nearly all users, Method 1 is safer and more effective. Manually adding the code can lead to errors if done incorrectly, and it does not automatically enable Shopify's enhanced e-commerce tracking.
Heads up: If you use this method, you MUST remove your Measurement ID from the Preferences section described in Method 1. Otherwise, you'll be tracking every pageview twice, which will completely mess up your data.
If you need to proceed:
In your GA4 analytics account, go back to your Web stream details (Admin > Data Streams > Click your stream).
Under "Installation instructions," click Install manually. This will reveal the full JavaScript tracking tag. Click the copy icon to copy the entire code block.
In your Shopify Admin, go to Online Store > Themes.
Find your current theme, click the ... button (Actions), and select Edit code.
In the code editor view, under the Layout folder on the left, click on the file named
theme.liquidto open it.Scroll through the code until you find the closing
</head>tag.Paste the entire Google Analytics code snippet on a new line just before the closing
</head>tag.Click Save.
Verifying Your Google Analytics Setup
After connecting GA4, you should always check to make sure it's working. The easiest way to do this is with the Realtime report in Google Analytics.
Go to your Google Analytics 4 property.
On the left navigation menu, click Reports > Realtime.
In a separate browser tab or on your phone, open your live Shopify store website and navigate to a few different pages.
Switch back to the GA4 Realtime report. Within a minute or so, you should see at least "1" appear in the "Users in Last 30 Minutes" card.
You may also see cards showing which pages you're viewing and what events are being triggered. If you see your activity show up here, your connection is successful and GA4 is actively collecting data from your store.
What to Track After You Connect Google Analytics
Now for the fun part. The setup is done, and data is flowing. Where do you start looking for insights?
Traffic Acquisition: Where Are People Coming From?
Go to Reports > Acquisition > Traffic acquisition. This report is your command center for understanding your marketing channels. It groups your visitors by source, such as:
Organic Search: Visitors who found you via a search engine like Google.
Paid Social: Visitors from ads on platforms like Facebook or Instagram.
Direct: Visitors who typed your URL directly into their browser.
Email: Visitors who clicked a link from one of your email campaigns.
Look at which channels drive the most traffic, but more importantly, which ones drive the most conversions and revenue. You might find that your Instagram posts get thousands of clicks, but your humble blog is driving customers who spend twice as much.
Landing Page Performance: What’s Their First Impression?
Go to Reports > Engagement > Landing page. This report shows you which pages are the most common entry points to your store. A landing page is the very first page a user sees in their session. You can analyze this report to see which product pages, collection pages, or blog posts are drawing people in and how well they perform in keeping users engaged.
Purchase Journey: How Do People Shop?
The beauty of Shopify's native integration is that it automatically tracks the e-commerce funnel. You can analyze this activity in GA4 to find leaks.
For instance, go to the Reports section and look for the "Monetization" reports. Here you can see which products are viewed the most, how many are added to carts, and your overall conversion rate. By building funnels in the "Explore" tab, you can visualize the journey - from view_item to add_to_cart to begin_checkout to purchase - and identify where potential customers are abandoning the process.
Final Thoughts
Connecting Google Analytics to your Shopify store is a massive step up from relying solely on Shopify's native dashboards. By pasting your Measurement ID into Shopify’s settings, you go beyond basic traffic counts to see precisely where your customers come from, what they do on your site, and what truly sparks their decision to buy.
Of course, getting your Shopify and Google Analytics data connected is just the beginning. The real challenge comes when you need to combine that information with data from your other marketing and sales tools - like Facebook Ads, Google Ads, or your email platform - to get a single, clear view of your business performance. That’s where we built Graphed to help. Instead of manually exporting CSVs and fighting with spreadsheets to build reports, you can connect all your data sources in minutes. Then, using simple, natural language, you can create real-time dashboards and get instant answers with prompts like, "Show me my return on ad spend for Google vs. Facebook last month, broken down campaign."