How to Set Up Google Analytics 4 on Shopify
Google Analytics 4 (GA4) is the current version of Google Analytics and provides powerful ecommerce tracking capabilities for Shopify stores. This guide covers the setup process, enhanced ecommerce tracking, custom events, and common issues you may encounter when connecting GA4 to Shopify.
Two Ways to Connect GA4 to Shopify
There are two primary methods for adding GA4 to your Shopify store, and it is important to understand the difference:
- The Google & YouTube sales channel app: This is the recommended method. It is a Shopify app that connects your Google account to your Shopify store and handles GA4 integration, Google Ads, and Google Merchant Center in one place.
- Manual placement via theme code: You can add the GA4 tracking tag directly to your Shopify theme's code. This gives you more control but requires technical knowledge and is more difficult to maintain.
For most stores, the Google & YouTube sales channel app is the better choice because it handles ecommerce event tracking automatically.
Setting Up via the Google & YouTube Sales Channel
- In your Shopify admin, go to Sales channels in the left sidebar.
- Click Add sales channel (or the + icon).
- Search for Google & YouTube and click Add channel.
- Once installed, click on the Google & YouTube channel in your sidebar.
- Click Connect Google account and sign in with the Google account that owns your GA4 property.
- Follow the prompts to connect your Google Analytics property. If you do not have a GA4 property yet, you can create one at analytics.google.com before this step.
- Select your GA4 property from the dropdown and complete the connection.
Once connected, Shopify automatically places the GA4 tracking code on all pages of your store, including the checkout and order confirmation pages.
Setting Up via Online Store Preferences (Legacy Method)
Shopify previously offered a simpler integration point under Online Store, then Preferences, where you could paste your Google Analytics tracking ID. This method has been updated to work with GA4, but Shopify now directs most users to the Google & YouTube sales channel instead. If you see a Google Analytics field under Online Store Preferences, you can enter your GA4 Measurement ID (which starts with G-) there. However, this method may not provide the same level of ecommerce event tracking as the sales channel app.
Enhanced Ecommerce Tracking
One of the biggest advantages of connecting GA4 to Shopify is ecommerce event tracking. When properly set up through the Google & YouTube sales channel, GA4 automatically tracks key ecommerce events:
| GA4 Event |
What It Tracks |
| view_item |
A customer views a product page |
| add_to_cart |
A customer adds a product to their cart |
| begin_checkout |
A customer starts the checkout process |
| add_payment_info |
A customer enters payment details |
| purchase |
A customer completes a purchase |
| view_item_list |
A customer views a collection or search results page |
These events include item-level data such as product name, product ID, category, price, and quantity. This data powers the ecommerce reports in GA4.
Custom Events with Google Tag Manager
If you need to track additional events beyond what Shopify sends automatically, you can use Google Tag Manager (GTM). To set up GTM on Shopify:
- Create a Google Tag Manager account and container at tagmanager.google.com.
- Add the GTM container code to your Shopify theme. Go to Online Store, then Themes, then Edit code. Paste the GTM snippet into your theme.liquid file, in the head and body sections as instructed by GTM.
- For checkout pages, Shopify Plus merchants can add GTM to checkout.liquid. Standard Shopify plans have limited access to customize checkout tracking, but the Google & YouTube sales channel handles the core checkout events.
- In GTM, create tags for any additional events you want to track, such as newsletter signups, video plays, or scroll depth.
Note that using both the Google & YouTube sales channel and GTM can sometimes result in duplicate event tracking. If you go the GTM route, be careful to avoid firing the same events twice. Many merchants use the sales channel for core ecommerce events and GTM only for supplementary custom events.
Viewing Ecommerce Data in GA4
Once data starts flowing from Shopify to GA4 (allow 24-48 hours for initial data), you can access ecommerce reports in several places:
- Monetization reports: In GA4, navigate to Reports, then Monetization. Here you will find the Ecommerce purchases report, which shows revenue, items purchased, and item-level performance.
- Ecommerce purchases: This report breaks down revenue by product, showing which items drive the most sales.
- Purchase journey: Under Reports, then Monetization, the Purchase journey report shows the funnel from session start through view_item, add_to_cart, begin_checkout, and purchase, with drop-off rates at each step.
GA4 Explorations for Ecommerce
GA4's Explorations feature lets you build custom analyses beyond the standard reports:
- Funnel Exploration: Build a custom checkout funnel showing exactly where customers drop off. Start with page_view on a product page, then add_to_cart, begin_checkout, and purchase. You can segment by traffic source, device, or geography to find specific conversion bottlenecks.
- Path Exploration: Visualize the paths customers take through your store before purchasing. This helps you understand which pages contribute to conversions.
- Segment Overlap: Compare different customer segments (e.g., mobile vs. desktop purchasers, or returning vs. new customers) to understand behavioral differences.
- Cohort Analysis: Track groups of customers over time to measure repeat purchase rates and customer lifetime value.
Explorations are available to all GA4 users for free and are one of the most powerful tools for understanding your Shopify store's performance.
Connecting Google Ads
If you run Google Ads campaigns to drive traffic to your Shopify store, linking GA4 to Google Ads provides valuable conversion data:
- In GA4, go to Admin (gear icon in the lower left).
- Under Product links, click Google Ads links.
- Click Link and select your Google Ads account.
- Enable auto-tagging and complete the link.
Once linked, your GA4 ecommerce events (including purchase events with revenue data) can be imported into Google Ads as conversions. This allows Google Ads to optimize your campaigns based on actual purchase data from your Shopify store, rather than just clicks.
Common Issues and Data Discrepancies
Shopify store owners frequently notice differences between Shopify's built-in analytics and GA4 data. Here are the most common causes:
- Ad blockers and browser privacy: GA4 relies on JavaScript tracking, which is blocked by many ad blockers and privacy-focused browsers. Shopify's own analytics use server-side data and are not affected by ad blockers. This means GA4 will almost always report fewer sessions and transactions than Shopify.
- Attribution differences: Shopify and GA4 use different attribution models. GA4 defaults to data-driven attribution across a 30-day lookback window, while Shopify uses last-click attribution. The same purchase may be attributed to different traffic sources in each platform.
- Checkout domain: On standard Shopify plans, checkout happens on checkout.shopify.com, which is a different domain than your store. This can cause session breaks in GA4. The Google & YouTube sales channel helps mitigate this, but it may not eliminate the issue entirely. Shopify Plus stores with custom checkout domains have fewer problems here.
- Currency and tax handling: Ensure GA4 and Shopify are reporting revenue in the same currency. Also check whether your GA4 purchase events include or exclude tax and shipping, as this varies by implementation.
- Delayed data: GA4 standard reports may take 24-48 hours to fully process. Realtime reports show current data but may not include all events. Do not compare GA4 data from the last 48 hours with Shopify's real-time dashboard.
- Duplicate tracking: If you have GA4 installed via both the sales channel and a manual theme code snippet, events will fire twice. Check your theme code and remove any manual GA4 snippets if you are using the sales channel.
Verifying Your Setup
After connecting GA4, verify that everything is working:
- Open your Shopify store in a browser (not in incognito, and without ad blockers).
- In GA4, go to Reports, then Realtime.
- You should see your visit appear as an active user.
- Browse a product page and add an item to your cart. Check that the view_item and add_to_cart events appear in the Realtime report.
- If you can, complete a test purchase and verify that the purchase event fires with correct revenue data.
You can also use the DebugView in GA4 (Admin, then DebugView) with the Google Analytics Debugger browser extension to see events in real time as they fire.