How to Set Up Google Analytics in Shopify
Your Shopify store is up and running, but simply knowing your total sales isn't enough. To truly grow, you need to understand visitor behavior, page performance, and which marketing efforts are actually bringing in paying customers. This guide will walk you through setting up Google Analytics on your Shopify store so you can get the powerful insights you need to make smarter business decisions.
Why You Need Google Analytics for Your Shopify Store
You might be thinking, "Doesn't Shopify already have analytics?" Yes, it does, and they're excellent for tracking store-centric metrics like sales, conversion rates, and average order value. Shopify Analytics gives you the "what" - what was purchased, what was the total revenue.
Google Analytics (specifically, Google Analytics 4 or GA4) gives you the "how" and "why." It focuses on a different, but equally important, set of data primarily centered around user acquisition and on-site behavior.
Connecting GA4 to Shopify unlocks a deeper level of understanding:
- User Acquisition: See exactly where your visitors are coming from. Is it organic search, a specific Facebook ad, an email campaign, or a referral from another website? Google Analytics breaks this down so you can double down on what works and cut spending on what doesn't.
- Audience Behavior: Discover which pages users visit most, how long they stay, and what path they take through your store before buying (or leaving). Are they dropping off at a specific product page? Is your blog driving traffic to product collections? GA4 can tell you.
- Full-Funnel Tracking: While Shopify shows you the final sale, Google Analytics can show you the entire journey leading up to it, from the initial
page_viewandadd_to_cartevents all the way through to thepurchaseconfirmation. - Detailed Goals & Events: You can track more than just sales. Set up custom goals to measure newsletter sign-ups, video views, or PDF downloads to get a complete picture of user engagement on your site.
Step 1: Set Up Your Google Analytics 4 Property
Before you can connect anything to Shopify, you need a Google Analytics 4 property to send data to. If you already have one, you can skip to Step 2. If you're new to GA4 or only used the older Universal Analytics, follow these steps to create one.
1. Create the GA4 Property
First, navigate to the Google Analytics website and sign in with your Google account. It's best to use the same account you use for your other business services like Google Ads.
- Once you're logged in, click the gear icon for Admin in the bottom-left corner.
- In the Property column, click the blue + Create Property button.
- Give your property a name, like "[Your Store Name] - GA4." Select your reporting time zone and the primary currency your store uses. Click Next.
- Provide some basic business information. For business size, choose the appropriate number of employees, and for your objective, select "Generate leads" or "Drive online sales." This helps Google tailor your setup slightly, but it's not critical to get perfect.
- Click Create and accept the terms of service.
2. Set Up a Web Data Stream
A "Data Stream" is the source of data for your GA4 property. For a Shopify store, this will be your website.
- After creating your property, you'll be prompted to choose a platform. Select Web.
- In the Website URL field, enter your Shopify domain (e.g.,
your-store-name.myshopify.comor your custom domain likewww.yourstore.com). Important: Do not includehttps://in this field. - Give the stream a name, like "[Your Store Name] Website."
- Ensure "Enhanced measurement" is turned on. It usually is by default, and it automatically tracks important actions like page views, clicks, and scrolls.
- Click Create stream.
3. Find Your "Measurement ID"
Once you create the stream, you'll get a page with stream details. The single most important piece of information here is your Measurement ID. It's a unique identifier that starts with "G-" followed by a string of letters and numbers (e.g., G-XYZ123ABC).
Copy this ID to your clipboard or a notepad. You'll need it in the next step to tell Shopify which Google Analytics property to send data to.
Step 2: Connect Shopify to Google Analytics via the Google & YouTube App
Shopify makes connecting to Google Analytics incredibly simple with its native "Google & YouTube" app. This is the official, recommended method because it automatically handles not just the tracking code, but also crucial e-commerce events. It's easy, fast, and doesn't require editing any code.
- Install the App: From your Shopify Admin dashboard, go to Apps on the left-hand navigation. You might already see an option for the "Google & YouTube" channel, if not, click "All recommended apps" and search for it, or go directly to the Shopify App Store. Click Add app and follow the installation prompts.
- Connect Your Google Account: The app will prompt you to connect the Google Account associated with the GA4 property you just created. Click Connect and sign in, granting the necessary permissions.
- Select Your GA4 Property: The setup wizard will then search your connected Google Account for existing properties. You'll see a dropdown menu. Find your GA4 property you created in Step 1 and select it. This is where you can double-check that the Measurement ID in the menu matches the one you saved.
- Complete the Setup: Your GA4 property should now be linked. The app will automatically place the required gtag.js tracking script on every page of your store, including the checkout process.
And that’s it! The app handles everything else behind the scenes. This method ensures all essential e-commerce events like page_view, view_item, add_to_cart, begin_checkout, and purchase are automatically tracked, giving you rich data in GA4 without any extra work.
Alternative Method: Adding the GA4 Code Manually
While the app is highly recommended, some users may prefer to add the code manually or may have a theme that conflicts with the app. This method gives you more control but also carries more risk and doesn't automatically track key e-commerce events beyond page views.
1. Find Your GA4 Global Site Tag
First, you need the full JavaScript code snippet. In your GA4 property, go to Admin > Data Streams and click on your Web stream. In the "Web stream details" panel, scroll down and click on Configure tag settings, and then under "Your Google Tag", click Installation instructions. From there, click on "Install manually". You'll see a box with a chunk of code that looks something like this:
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-YOURMEASUREMENTID"></script>
<script>
window.dataLayer = window.dataLayer || [],
function gtag(){dataLayer.push(arguments),}
gtag('js', new Date()),
gtag('config', 'G-YOURMEASUREMENTID'),
</script>2. Add the Code to Your theme.liquid File
From your Shopify Admin:
- Go to Online Store > Themes.
- On your current theme, click the three-dots icon and select Edit code.
- Under the Layout folder, find and click on the
theme.liquidfile. This is the main template that loads on almost every page of your store. - Scan through the code and find the opening
<head>tag near the top. Paste your entire Global Site Tag snippet on a new line immediately after this tag. - Click Save.
3. Add the Code to Checkout Pages
Theme files do not control the checkout process, so you need to add your code there separately.
- In your Shopify Admin, go to Settings > Checkout.
- Scroll down to the Order status page section. Underneath it, you will see a box labeled Additional scripts.
- Paste the exact same Global Site Tag snippet into this box.
- Click Save.
This ensures your tag fires not only on your product and collection pages but also on the order confirmation page after a purchase is completed.
Warning: The manual method does not automatically set up Enhanced Ecommerce tracking. You'll get pageview data, but you won't get data on products viewed, items added to carts, or transaction details without significant custom coding. For 99% of store owners, the Google & YouTube app is the far better choice.
How to Test Your Google Analytics Setup
Once you've installed your tracking code using either method, you need to make sure it's working. Don't just assume - verify!
The easiest way is to use Google Analytics' Realtime report:
- Keep your GA4 account open in one browser tab. Navigate to Reports > Realtime.
- In a separate browser window (preferably an incognito window to avoid cookies), open your Shopify store's homepage.
- Click around your store for a minute. Visit a product page, then a collection page.
- Switch back to your GA4 Realtime report tab. You should see a "1" in the "Users in last 30 minutes" card. The map should show your location, and the Event count card should show events like
page_viewandsession_startfiring.
If you see your activity appear, congratulations! Your Shopify store is now successfully sending data to Google Analytics.
Final Thoughts
Connecting Shopify to Google Analytics empowers you with a much deeper understanding of your customer journey and marketing effectiveness. By moving beyond basic sales data, you can see exactly which channels are driving qualified traffic, understand how users interact with your store, and make data-backed decisions to optimize your performance.
Getting the data into Google Analytics is just the first step. The next challenge is making sense of it all, especially when combining GA4 data with performance metrics from your ad platforms, email tool, and CRM. That's why we built Graphed. We connect directly to your Shopify store, Google Analytics, social ad accounts, and more, letting you use simple conversational language to build dashboards and get insights instantly. Instead of being buried in GA4 menus, you can just ask, "Show me my conversion rate from Facebook Ads compared to organic search this month," and get an answer and a visualization in seconds, helping you move from raw data to smart decisions.
Related Articles
How to Connect Facebook to Google Data Studio: The Complete Guide for 2026
Connecting Facebook Ads to Google Data Studio (now called Looker Studio) has become essential for digital marketers who want to create comprehensive, visually appealing reports that go beyond the basic analytics provided by Facebook's native Ads Manager. If you're struggling with fragmented reporting across multiple platforms or spending too much time manually exporting data, this guide will show you exactly how to streamline your Facebook advertising analytics.
Appsflyer vs Mixpanel: Complete 2026 Comparison Guide
The difference between AppsFlyer and Mixpanel isn't just about features—it's about understanding two fundamentally different approaches to data that can make or break your growth strategy. One tracks how users find you, the other reveals what they do once they arrive. Most companies need insights from both worlds, but knowing where to start can save you months of implementation headaches and thousands in wasted budget.
DashThis vs AgencyAnalytics: The Ultimate Comparison Guide for Marketing Agencies
When it comes to choosing the right marketing reporting platform, agencies often find themselves torn between two industry leaders: DashThis and AgencyAnalytics. Both platforms promise to streamline reporting, save time, and impress clients with stunning visualizations. But which one truly delivers on these promises?