How to Set Up Google Analytics 4 Conversion Tracking on Shopify

Cody Schneider

Setting up Google Analytics 4 conversion tracking on Shopify is the first step toward truly understanding what's working - and what's not - in your store. Instead of just looking at traffic, successful tracking shows you which marketing channels, campaigns, and pages are actually generating sales. This guide will walk you through the essential steps to accurately track purchase conversions on your Shopify store using GA4.

Good, Better, Best: Three Ways to Install GA4 on Shopify

Before we jump into the setup, it's important to understand your options. There are three common methods for integrating Google Analytics 4 with Shopify, each with its own advantages.

  • Good (Beginner): The Built-in Shopify Integration. Shopify's native Google Channel app is the fastest way to get started. It automatically handles basic tracking for page views, adding products to the cart, starting checkouts, and purchases. It's simple and requires no code, making it perfect for beginners. The downside is a lack of control and occasional data discrepancies.

  • Better (Intermediate): Manually Adding Code to Your Theme. This method involves inserting the GA4 tracking code (gtag.js) directly into your Shopify theme files and the "Additional scripts" box in your checkout settings. This gives you more control and accuracy, especially for the crucial purchase event and its value. This is the method we'll detail below because it provides a highly reliable foundation.

  • Best (Advanced): Using Google Tag Manager (GTM). GTM is an incredibly powerful tool that lets you manage all your tracking tags (GA4, Google Ads, Facebook Pixel, etc.) from one dashboard. It offers the most flexibility for adding custom tracking but comes with a steeper learning curve. For simplicity and reliability, we'll focus on the manual code method, which strikes a great balance for most store owners.

Step 1: Create a Google Analytics 4 Property and Data Stream

If you haven't already, your first task is to set up a property in Google Analytics. This is where all your website's data will live.

Create Your GA4 Property

  1. Navigate to the Google Analytics homepage and click "Admin" in the bottom-left corner.

  2. In the "Account" column, make sure your correct account is selected. Then, in the "Property" column, click the big blue "Create Property" button.

  3. Enter your store's name for the "Property name," select your reporting time zone, and choose your store's primary currency. Getting the currency right is crucial for accurate revenue tracking.

  4. Click "Next," fill out the business details, and click "Create."

Create & Configure Your Web Data Stream

  1. You'll be prompted to "Choose a platform." Select "Web."

  2. Enter your store's URL (e.g., www.yourstore.com) and give the stream a creative name like "Shopify Store Web Stream."

  3. Make sure "Enhanced measurement" is turned on. This feature automatically tracks important interactions like outbound clicks and site searches without extra setup.

  4. Click "Create Stream."

Once created, you'll see a screen with your stream details. Find your "Measurement ID" (it starts with "G-"). Copy this ID, you'll need it in the next step.

Step 2: Add the GA4 Tracking Tag to Your Shopify Theme

Now it's time to add the base GA4 tracking script to your Shopify store. This ensures that every page on your site has the necessary code to send data, like page views, to your GA4 property.

  1. From your Shopify Admin dashboard, go to Online Store > Themes.

  2. Find your current theme and click the three-dots icon (also called the action menu), then select "Edit code."

  3. In the file search bar on the left, look for a file called theme.liquid. This is the main template file for your entire store.

  4. Find the closing </head> tag. It's usually near the top of the file.

  5. Right before the </head> tag, paste the following Google Tag (gtag.js) script. Be sure to replace YOUR-G-ID-HERE with your actual Measurement ID from Step 1.

Click "Save." This code will now be present on every page of your store except for the sensitive checkout and thank you pages, which we'll handle next.

Step 3: Manually Track Your Purchase Conversions

Tracking the purchase event with all of its valuable data (like order total, currency, items purchased, etc.) is the most important part of e-commerce analytics. Because Shopify locks down its checkout pages, the one place we can add a script to track sales is on the order confirmation page.

  1. From your Shopify Admin, click on Settings in the bottom-left corner.

  2. In the Settings menu, navigate to Checkout.

  3. Scroll all the way down until you find the "Order status page" section. Here, you'll see a text box titled "Additional scripts."

  4. This is where you'll paste a special script that fires only when a customer successfully completes a purchase.

Copy and paste the script below into the "Additional scripts" box. Again, don't forget to replace YOUR-G-ID-HERE with your own Measurement ID.

A Quick Explanation of The Code: This script uses Shopify's Liquid templating language (the bits inside {{ }}) to dynamically pull order information right after a purchase. It populates an official GA4 'purchase' event with transaction details like the Order ID, total value, currency, tax, shipping, and a detailed list of every item bought. The {% if first_time_accessed %} check prevents the script from firing if a customer reloads their thank-you page, avoiding duplicate conversions.

When you're done, click "Save."

Step 4: Verify Your Conversion Tracking is Working

Next, you’ll want to make sure the tags are actually firing. Waiting 24-48 hours for data to show up in standard reports is not ideal. Instead, use Google Analytics' real-time debugging tool.

  1. First, install the free GA Debugger Chrome extension.

  2. Once installed, navigate to your Shopify store and click on the extension's icon in your toolbar. A console window will pop up at the bottom of your browser - you can ignore it, just make sure the extension is active ("ON").

  3. Now, open a new browser tab and go to your Google Analytics dashboard. In the left navigation, go to Admin, then scroll down to "DebugView."

  4. With DebugView open, go back to your store tab and browse a few pages. You should see events like page_view and session_start appearing in real time in the DebugView timeline.

  5. To test the conversion, go through a full checkout process on your Shopify store. Placing a small test order is the easiest way to do this. After you complete the purchase and land on the thank you page, look back at the DebugView.

You should see a green "purchase" event pop up in the timeline. Click on it. A new panel will open, showing you all the parameters sent with the event. Verify a transaction_id is present, and check that the value and currency successfully match your test order. Success!

Step 5: Mark the Purchase Event as an Official Conversion

Just because Google Analytics is receiving your 'purchase' event doesn't mean it's counting it as an official "conversion" in its core reports. You need to explicitly tell it to do so.

  1. In GA4, go to Admin > Data display > Events.

  2. You'll see a table listing all the event names being collected. Wait a day or two and you should see "purchase" in this list of existing events.

  3. Once "purchase" appears, simply find it in the list and toggle the "Mark as conversion" switch to the "on" position. That's it.

  4. Alternatively, you can go to Admin > Data display > Conversions and click "New conversion event." When it asks for the event name, type "purchase" and click save.

Going forward, GA4 will treat every 'purchase' event as a primary conversion, making it available in all your attribution and performance reports.

Important: Avoid Double-Counting! A Note on the Shopify Integration

A common mistake is having both the native Shopify Google Channel app and the manual code installed simultaneously. This can lead to your data being counted twice: once by a simple pageview from the native app on the confirmation page and once by your much more detailed manual 'purchase' event script.

If you've followed the manual code approach above, we recommend disabling the Shopify-native Google Analytics integration to prevent any conflicts.

  1. In Shopify Admin, go to Online Store -> Preferences.

  2. Look for the Google Analytics section. If you have an old Universal Analytics (UA-) code there, remove it.

  3. Ensure that there is NO Google Analytics Measurement ID here. Having our code in Themes > Edit Code and in Checkout > Additional Scripts means we are manually taking care of all the tracking needed.

By relying exclusively on the manual code, you ensure you're sending one, clean, high-quality purchase event for every sale, which makes all your downstream analysis a breeze.

Final Thoughts

You've successfully set up your Shopify store to track purchase conversions in Google Analytics 4. By inserting the tag into your theme and adding the dynamic script to your checkout, you're now sending rich, accurate conversion data that is essential for understanding your store performance, ad campaign ROI, and customer purchase paths.

Bringing your Shopify conversion data into GA4 is just the beginning. The real goal is to analyze that data alongside your ad spend from Facebook Ads, sessions from Google Ads, and campaign opens from Klaviyo to get a complete picture of your performance. Instead of drowning in spreadsheets, we built Graphed to unify all your marketing data automatically. We connect instantly to your Shopify, GA4, and ad platforms, and let you create real-time charts and dashboards just by asking questions in plain English - no complicated setup required.