Where to Install Google Analytics in Shopify?

Cody Schneider

Want to track your Shopify store's performance with Google Analytics? You're in the right place. While Shopify has its own reporting, Google Analytics gives you a much deeper understanding of your visitors - who they are, where they came from, and how they behave on your site. This article walks you through where and how to install Google Analytics in Shopify using two different methods, helping you choose the best one for your store.

Why Bother Using Google Analytics with Shopify?

You might be wondering if Shopify's built-in analytics is good enough. It’s a great starting point for seeing your sales, top products, and conversion rates. However, Google Analytics complements it by answering questions Shopify can't, giving you a serious advantage.

Here’s what GA brings to the table:

  • Deeper Audience Insights: Go beyond basic location data. Learn about your visitors' ages, genders, interests, and the devices they use. This helps you refine your marketing messages and target the right people.

  • Full Customer Journey Tracking: See how different channels work together. A customer might discover your brand on Instagram, visit your site a few times from a Google search, and finally make a purchase after clicking an email link. GA shows you that entire path.

  • Robust Goal and Event Tracking: Track more than just sales. You can measure newsletter sign-ups, video plays, PDF downloads, or "add to cart" clicks without a purchase. This helps you understand what on-site actions lead to conversions.

  • Powerful Integrations: Connect Google Analytics with other essential tools like Google Ads and Google Search Console. This allows you to see how your ad spend turns into revenue and which search terms are driving organic traffic to your product pages.

In short, Shopify Analytics tells you what is happening in your store. Google Analytics tells you who is doing it and why.

Choose Your Method: The Easy Way vs. The Manual Way

There are two primary methods for adding Google Analytics to your Shopify store. It’s important to choose only one to avoid double-counting your traffic and getting inaccurate data.

  1. Use Shopify's Google & YouTube App: This is the official, recommended method for Google Analytics 4. It’s simple, code-free, and handles all the necessary e-commerce event tracking for you automatically.

  2. Manually Add the Tracking Code to Your Theme: This method involves editing your theme’s code. It's for users with more advanced needs, like implementing a custom tracking setup through Google Tag Manager or troubleshooting issues with the native integration.

For over 95% of Shopify store owners, the first method is the correct choice. Let's start there.

Method 1: Shopify's Google & YouTube App (Recommended)

This is the fastest and safest way to connect your store to Google Analytics 4. It literally takes a few clicks.

Before You Start: Get Your GA4 Measurement ID

To use this integration, you first need a Google Analytics 4 property for your website. If you don't have one yet, head over to Google Analytics, create an account, and set up a new property for your store.

Once it's set up, you'll need its unique "Measurement ID." Here’s how to find it:

  1. Log in to your Google Analytics account.

  2. Click the Admin gear icon in the bottom-left corner.

  3. Under the 'Property' column, click on Data Streams.

  4. Select the data stream for your website.

  5. Your Measurement ID (formatted as G-XXXXXXXXXX) will be in the top right. Copy it.

Step-by-Step Installation Guide

With your Measurement ID ready, connecting it to Shopify is easy.

1. Navigate to the Google & YouTube channel

From your Shopify admin dashboard, look for "Sales channels" on the left-hand menu. If you don't instantly see "Google & YouTube," click "Apps and sales channels," search for it, and add it to your store.

2. Connect Your Google Account

Open the Google & YouTube channel. You'll see a setup screen. Find the Google Analytics section and click "Get started" or "Connect." You will be prompted to choose the Google account associated with the GA4 property you just created.

Make sure you grant Shopify the necessary permissions to manage your Google Analytics data.

3. Select Your GA4 Property

After you’ve connected your Google account, Shopify will display a list of GA4 properties it found. Simply select the correct one from the dropdown menu (using the Measurement ID you copied earlier to confirm). Click "Connect," and you're done! Shopify will inject the required tracking code across all pages of your site, including checkout.

That's it. This integration automatically tracks key e-commerce events like view_item, add_to_cart, and purchase, sending that rich data straight to your Google Analytics reports.

How to Verify Your Google Analytics Is Working

Don't just assume it's working, take a minute to verify. The easiest way is using the 'Realtime' report in GA4.

  1. Keep your Google Analytics account open in one browser tab.

  2. Navigate to Reports > Realtime.

  3. In a separate tab or your phone, open your live Shopify store. Browse a few pages.

  4. Go back to the GA4 Realtime report. Within about 30 seconds, you should see your own visit pop up in the "Users in last 30 minutes" card. You might also see your location on the map.

If you see activity, congratulations! Your tracking is active. Keep in mind that standard GA4 reports can take 24-48 hours to fully populate with new data, so don't be alarmed if they look empty at first.

Method 2: Manually Adding the Tracking Code (Advanced Users)

You should only use this method if you have a specific reason to avoid Shopify's native integration. For example:

  • You use Google Tag Manager (GTM) to manage all your marketing tags.

  • You need to add highly customized event tracking that the default setup doesn't cover.

  • The native integration is having a technical issue.

  • You want to run a tracking script from a non-Google analytics service alongside GA.

Warning: Improperly editing your theme code can break your website. Before you start, always create a backup by going to Online Store > Themes, clicking the three-dot menu on your current theme, and selecting "Duplicate." If you make a mistake, you can always revert to this saved copy.

Step 1: Get the GA4 Global Site Tag (gtag.js)

First, you need the full JavaScript snippet from Google Analytics.

  1. In GA4, go to Admin > Data Streams > [Your Web Stream].

  2. Under "Google tag," click on View tag instructions.

  3. Select the Install manually tab.

  4. Copy the entire code block that starts with <!-- Google tag (gtag.js) -->.

Step 2: Add the Code to theme.liquid

The code needs to be placed within the <head> section of your theme's code, ensuring it loads on every single page of your store.

  1. In your Shopify admin, go to Online Store > Themes.

  2. Click the three-dot menu on your theme and choose Edit code.

  3. From the file list on the left, find and open the theme.liquid file. This is the master template for your store.

  4. Scroll down until you find the opening <head> tag.

  5. Paste the entire Google Tag snippet you copied right after the <head> tag.

  6. Click Save.

The global site tag is now installed. This will track page views and basic user data across your site.

Step 3: Track Conversions (Optional but Recommended)

Adding the code to theme.liquid will not track e-commerce specifics like which product was purchased or how much an order was worth. To capture this crucial conversion data, you need to add scripts to the checkout thank you page.

  1. Navigate to Settings > Checkout in your Shopify admin.

  2. Scroll down to the Order status page section.

  3. In the Additional scripts box, you'll need to paste a custom event snippet. This code is more complex as it needs to dynamically pull order information like transaction ID and value. You would typically construct this event snippet based on Google's documentation for purchase events.

Again, this is complex and highlights why using the native integration is better for most people - it handles all of this automatically.

Common Problems to Avoid

Duplicate Tracking is Your Enemy

The most common mistake is using both methods at once. If you enable the Google & YouTube app and have manually pasted the gtag.js code into theme.liquid, your site will send two pageview hits for every page a user visits. This inflates your traffic numbers, screws up your bounce rate, and makes your data completely unreliable.

Always pick one method. If you're switching from the manual method to the easy integration, make sure you go back into theme.liquid and delete the old code you added.

Why is Data Not Showing Up?

If you verified with the Realtime report but don't see anything in standard reports, be patient. As mentioned, it can take up to 48 hours for data to be processed and appear.

Also, check for these common culprits:

  • Ad Blockers: Your own browser's ad blocker might be blocking GA. Try verifying from a different device or in an incognito window with extensions turned off.

  • Internal Filters: You may have set up filters in Google Analytics to exclude traffic from your home or office IP address. Make sure you're not accidentally filtering yourself out during testing.

Final Thoughts

Connecting Google Analytics to Shopify is a foundational step for turning raw data into meaningful business decisions. For the vast majority of store owners, Shopify's ready-to-go Google & YouTube app is the best choice - it's simple, accurate, and automatically tracks your e-commerce events without you having to touch a line of code. For those with unique, complex needs, manually adding the tag to your theme.liquid file offers endless flexibility, as long as you proceed with caution.

After your data starts flowing in, the next step is making sense of it all. This often means trying to decipher complex reports when you just need quick, clear answers. We built Graphed for this exact reason. We make it easy to connect your Shopify, Google Analytics, and ad accounts in one place. You can instantly create real-time dashboards and even ask questions about your performance like, "which Facebook campaigns drove the most sales last month?" to get an immediate answer.