How to Connect Shopify to Google Analytics 4

Cody Schneider9 min read

Connecting your Shopify store to Google Analytics 4 is one of the most powerful steps you can take to understand exactly how your marketing efforts are turning into sales. While Shopify's own analytics are great for a quick overview, GA4 helps you see the complete customer journey, from the first ad they see to the final purchase. This guide will walk you through the different ways to get your store connected, explaining the pros and cons of each method.

Why You Need More Than Just Shopify Analytics

Shopify's built-in reports are fantastic for understanding your sales, product performance, and basic traffic sources. But they don't tell the whole story. By connecting to GA4, you unlock a much deeper layer of insight into user behavior and marketing effectiveness.

  • Track the Full Customer Journey: See which marketing channels brought a customer to your site, what pages they visited, and whether they ultimately made a purchase. Did that Facebook ad lead to a browse session last week and a direct visit to buy today? GA4 can connect those dots.
  • Detailed Marketing Analysis: Uncover which campaigns, ad groups, or even specific keywords are driving the most valuable traffic. You can go beyond just knowing which channel worked and see which specific part of that channel is performing best.
  • Build Smarter Audiences: Use GA4 behavioral data to create highly specific audiences for Google Ads remarketing campaigns— for example, you can target users who added an item to their cart but didn't check out, or those who visited a specific product category multiple times.
  • Understand On-Site Behavior: Learn which pages are your top entry points, which ones cause visitors to leave, and the common paths people take before buying. This helps you optimize your store layout, product descriptions, and overall user experience.

In short, Shopify tells you what happened (sales, AOV), while GA4 tells you the how and why behind user actions, giving you a complete performance picture.

Before You Begin: Get Your GA4 Measurement ID

Every GA4 setup method requires your "Measurement ID." This is the unique identifier that tells Shopify where to send your website data. If you've already created a GA4 property, grabbing this ID is quick. If not, setting one up takes just a few minutes.

First, log in to your Google Analytics account.

If You Need to Create a New GA4 Property:

  1. Click Admin (the gear icon) in the bottom-left corner.
  2. In the Property column, click Create Property.
  3. Enter a name for your property (e.g., "My Shopify Store"). Select your reporting time zone and currency. Click Next.
  4. Answer the business information questions and click Create.
  5. When asked to choose a platform, select Web.
  6. Enter your website URL (e.g., www.yourstore.com) and give the stream a name (e.g., "Shopify Web Stream"). Click Create stream.

Finding Your GA4 Measurement ID:

Once you've created a stream, the Web stream details page will display your Measurement ID. It starts with "G-" followed by a mix of numbers and letters. It will look something like this: G-ABC123XYZ4.

If you're coming back to an existing GA4 property, you can find the ID by going to: Admin > Data Streams > [Click on your web stream]. Copy this "G-" ID somewhere handy—you'll need it in the next steps.

Method 1: Shopify's Native Google Channel App (The Easiest Way)

The simplest and most direct way to get started is by using Shopify's free Google & YouTube channel app. This method handles all the necessary script installations automatically and is ideal for store owners who want a straightforward setup without touching any code.

Step-by-Step Instructions:

  1. From your Shopify Admin dashboard, go to the sales channel section in the left-hand menu. If you don't already have it, click the (+) and add the Google & YouTube app.
  2. Once the app is installed, go through its initial setup and connect the Google account associated with your manager accounts.
  3. Within the app's settings, you'll find a section for Google Analytics. Here, it will prompt you to connect your GA4 property.
  4. Select your property from the dropdown list. The app will automatically find the "G-" Measurement ID associated with it.
  5. Once connected, the app takes care of everything. It adds the required gtag.js script to every page of your theme and sets up tracking for standard e-commerce events like page_view, view_item, add_to_cart, and purchase.

Pros and Cons of This Method:

  • Pros: Absolutely the easiest method. No coding involved, it's officially supported by Shopify, and it's free. Your setup will be complete within five minutes.
  • Cons: Lacks customization. This method sets up standard e-commerce tracking, which is great for most users, but it doesn't give you control over adding custom events or modifying how data is sent. It's a "one-size-fits-all" solution.

Method 2: Manually Adding Code to Your Theme Files (For More Control)

If you're comfortable editing a bit of code or need more advanced control, you can add the GA4 tracking scripts directly to your Shopify theme. This method ensures that the GA4 tag is loaded on every page and gives you a foundation to add more custom event tracking later on.

Heads Up: Before you make any changes, always duplicate your current theme to create a backup. Just go to Online Store > Themes, click the three dots on your live theme, and select Duplicate.

Step 1: Add the Global Site Tag

  1. Go back to your GA4 property: Admin > Data Streams > [Your Web Stream].
  2. Scroll down to the View tag instructions section. Switch to the Install manually tab and copy the entire gtag.js code block.
  3. In your Shopify Admin, navigate to Online Store > Themes. Click the three dots on your theme and choose Edit code.
  4. In the file browser on the left, open the theme.liquid file.
  5. Paste the entire code you copied from GA4 right after the opening <head> tag.
  6. Click Save.

This action installs the base GA4 tag across your entire store, which is enough to start tracking page views, sessions, and visitor demographics. However, it does not track e-commerce actions like purchases or add-to-carts.

Step 2: Add E-commerce Purchase Tracking

To capture purchase data, you need to add a special code snippet to the checkout "Thank you" page.

  1. In your Shopify Admin, go to Settings > Checkout.
  2. Scroll down to the Order status page section and look for the box labeled Additional scripts.
  3. Paste the following code block into the box. This code snippet uses Shopify's Liquid objects to dynamically pull order information and send it to GA4 when a purchase event occurs.
<script>
if (Shopify.checkout) {
  gtag('event', 'purchase', {
    "transaction_id": "{{ checkout.order_number }}",
    "affiliation": "{{ shop.name }}",
    "value": "{{ checkout.total_price | money_without_currency | remove: ',' }}",
    "currency": "{{ checkout.currency }}",
    "tax": "{{ checkout.tax_price | money_without_currency | remove: ',' }}",
    "shipping": "{{ checkout.shipping_price | money_without_currency | remove: ',' }}",
    "items": [
      {% for line_item in checkout.line_items %}
        {
          "item_id": "{{ line_item.sku }}",
          "item_name": "{{ line_item.product.title }}",
          "item_variant": "{{ line_item.variant.title }}",
          "price": "{{ line_item.original_price | money_without_currency | remove: ',' }}",
          "quantity": "{{ line_item.quantity }}"
        }{% unless forloop.last %},{% endunless %}
      {% endfor %}
    ]
  }),
}
</script>
  1. Click Save.

This approach gives you direct control but can be brittle. Theme updates might overwrite your changes in theme.liquid, and this only covers purchase events. Tracking other events like add_to_cart requires adding more specific snippets to other theme files (like product.liquid), which can become complex quickly.

Method 3: Using a Third-Party App from the Shopify App Store

For store owners who need robust tracking without the risk of manual coding, a dedicated analytics app is the perfect middle ground.

Dozens of apps in the Shopify App Store are built specifically to bridge the gap between Shopify and GA4. These apps manage a complex data layer implementation for you, reliably tracking the full suite of e-commerce events (view_item, add_to_cart, initiate_checkout, purchase, etc.) without requiring you to touch any code.

General Steps:

  1. Visit the Shopify App Store and search for "Google Analytics 4" or "GA4 eCommerce."
  2. Look for apps with high ratings and recent reviews. Read their features to ensure they support the standard events you want to track.
  3. Install your chosen app and follow their guided setup process, which typically just involves adding your GA4 Measurement ID in the app's dashboard.

Pros and Cons of This Method:

  • Pros: The most comprehensive and reliable method for most merchants. Tracks many e-commerce events out of the box, often provides developer support, and survives theme updates seamlessly.
  • Cons: Most of these apps come with a monthly subscription fee, although their cost is often far less than the developer hours it would take to build a custom solution.

How to Verify That Your Tracking is Working Correctly

Don't just set it and forget it! After setting up your connection, you must verify that data is actually flowing into your GA4 property.

1. Check the Realtime Report

The simplest check is to use the Realtime report. After implementing your tracking code:

  • Open your Shopify store in a new browser tab and navigate through a few pages.
  • In your GA4 property, go to Reports > Realtime.
  • Within a minute, you should see yourself appear in the "Users in the last 30 minutes" report. Clicking around your store should update the page_view count in the event cards.

2. Use DebugView for E-commerce Events

To confirm that your sales data is being tracked, DebugView is your best friend. This requires using the Google Analytics Debugger Chrome extension or GA4's Preview Mode.

  • Enable the GA Debugger extension for your site or use GA4's data stream preview mode.
  • Go back to your store and complete a test purchase funnel: view a product, add it to your cart, and complete a test checkout.
  • In GA4, go to Admin > DebugView.
  • Here, you should see a live stream of the events firing from your browser. Look for view_item, add_to_cart, and most importantly, purchase. Clicking on the purchase event will show you all the parameters attached, like transaction_id, value, and the items purchased. If you see this, your setup is a success!

Final Thoughts

Connecting Shopify to GA4 is essential for making data-driven decisions that grow your store. Whether you choose the simple Google Channel app, a more hands-on manual setup, or a robust third-party app, getting this tracking in place gives you the customer behavior insights you need to optimize your marketing spend and improve your store's conversion rates.

Of course, getting the data into GA4 is just the first step. The next challenge is translating that raw data into clear, actionable reports that tie your platform data together. At Graphed, we handle this for you. After you link your data sources like Google Analytics and Shopify just once, you can ask questions in plain English like "Show me a dashboard comparing Facebook Ads spend vs Shopify revenue by campaign" and get a live, automated dashboard in seconds. We help you skip the manual report building so you can get right to the insights that matter.

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.