Skip to content

How to Set Up Google Analytics 4 on Shopify (Complete Guide)

Create a GA4 property with a web data stream, then connect it in your Shopify admin, or add its Measurement ID through Google Tag Manager for custom events. Test in DebugView, and don't do both, or events get counted twice.

Three platforms, three answers, one budget to defend. Your GA4 export already holds the answer, and the first finding is free and never leaves your browser. Get your first finding free

By , Founder & CEOUpdated 12 min read

How to Set Up Google Analytics 4 on Shopify (Complete Guide)

Quick Answer: Setting up Google Analytics 4 (GA4) on Shopify involves creating a GA4 property in your Google Analytics account, obtaining your Measurement ID, and then integrating it directly through Shopify's admin panel or via Google Tag Manager for more advanced configurations. This process ensures your ecommerce store captures critical user behavior data for informed decision-making.

For Shopify merchants, understanding user interactions, conversion paths, and overall store performance is paramount. Google Analytics 4, with its event-driven data model, offers a reliable framework for this analysis, moving beyond the session-based limitations of its predecessor, Universal Analytics. This guide will walk you through the precise steps to integrate GA4 with your Shopify store, ensuring you can use its capabilities for enhanced data collection.

Understanding Google Analytics 4 for Shopify Merchants

Google Analytics 4 represents a significant shift in web analytics, designed to provide a more complete view of the customer lifecycle across various platforms and devices. Unlike Universal Analytics, which focused on page views and sessions, GA4 prioritizes events and user properties. This event-centric approach is particularly beneficial for ecommerce, as it allows for detailed tracking of specific actions like product views, additions to cart, checkout steps, and purchases, providing a richer data set for analysis.

For Shopify merchants, migrating to or implementing GA4 is no longer optional, as Universal Analytics ceased processing new data as of July 1, 2023. GA4 offers several advantages, including improved cross-device tracking, enhanced machine learning capabilities for predictive insights, and a more flexible data model that can be tailored to specific business needs. Its integration with Google Ads and other Google products also streamlines advertising efforts and attribution modeling.

Key Benefits of GA4 for E-commerce

Event-Driven Data Model: Tracks every interaction as an event, offering greater flexibility and depth in understanding user behavior.

Enhanced Ecommerce Tracking: Provides predefined and custom events for detailed tracking of the entire purchase funnel, from product impressions to successful transactions.

Cross-Platform Data Collection: Unifies data from websites and apps, offering a complete view of the customer journey.

Predictive Capabilities: uses machine learning to forecast future trends, such as purchase probability and churn risk.

Improved User Interface: A more intuitive reporting interface focused on user engagement and monetization.

Step-by-Step GA4 Setup on Shopify

Integrating Google Analytics 4 with your Shopify store can be accomplished through a few methods, ranging from a direct integration within Shopify's admin to more advanced setups using Google Tag Manager.

Method 1: Direct Integration via Shopify Admin (Basic Setup)

This is the simplest method and is suitable for merchants who need basic ecommerce tracking without extensive customization.

1. Create a Google Analytics 4 Property:

Go to analytics.google.com and log in with your Google account.

Click "Admin" (the gear icon) in the bottom-left corner.

In the "Account" column, select the desired account, or create a new one if necessary.

In the "Property" column, click "Create Property."

Enter a "Property name" (e.g., "Your Store Name GA4").

Select your "Reporting time zone" and "Currency." Click "Next."

Provide your "Industry category" and "Business size." Choose how you intend to use Google Analytics (e.g., "Measure customer engagement," "Refine my ad spend"). Click "Create."

2. Set Up a Data Stream:

After creating the property, you'll be prompted to choose a platform. Select "Web."

Enter your Shopify store's URL (e.g., https://www.yourstore.com). Ensure "Enhanced measurement" is enabled (it usually is by default).

Enter a "Stream name" (e.g., "Shopify Website"). Click "Create stream."

You will then see your "Measurement ID" (e.g., G-XXXXXXXXXX). Copy this ID.

In your Shopify admin, install the Google & YouTube sales channel.

GA4 isn't added under "Online Store" > "Preferences."

Shopify's direct integration typically tracks core ecommerce events such as add_to_cart, begin_checkout, and purchase. However, the level of detail and the range of events might be limited compared to a Google Tag Manager setup.

Method 2: Google Tag Manager (GTM) for Advanced Tracking

For merchants requiring more complete data collection, custom events, or integration with other marketing tags, Google Tag Manager is the preferred method. GTM acts as an intermediary, allowing you to manage all your website tags (including GA4) from a single interface without directly modifying your Shopify theme code for every change.

1. Set Up Google Tag Manager:

Go to tagmanager.google.com and log in with your Google account.

Click "Create Account" or select an existing account.

Enter an "Account Name" (e.g., "Your Store Name").

Enter a "Container Name" (e.g., "Your Store Name Web"). Select "Web" as the target platform. Click "Create."

You will be presented with the GTM installation code. Copy both the <head> and <body> snippets.

2. Add GTM to Shopify:

Log in to your Shopify admin panel.

Navigate to "Online Store" > "Themes."

Click "Actions" next to your current theme, then select "Edit code."

In the "Layout" section, click theme.liquid.

Paste the GTM <head> snippet immediately after the <head> tag.

Paste the GTM <body> snippet immediately after the <body> tag.

Click "Save."

3. Configure GA4 in GTM:

Go back to your Google Tag Manager workspace.

Create a new Tag:

  • Click "Tags" > "New."
    • Tag Type: "Google Analytics: GA4 Configuration."
    • Measurement ID: Enter your GA4 Measurement ID (G-XXXXXXXXXX).
    • Triggering: Select "All Pages." This ensures the GA4 base tag fires on every page load.
    • Name your tag (e.g., "GA4 Configuration - All Pages").
    • Click "Save."

4. Implement Enhanced Ecommerce Tracking via GTM (Recommended):

Shopify's default data layer doesn't always provide all the necessary information for complete GA4 ecommerce events out-of-the-box. You will likely need to enhance your Shopify data layer or use a third-party app to push the required data to GTM. Many Shopify apps or custom code snippets can be found that push GA4 ecommerce events (like view_item, add_to_cart, begin_checkout, purchase) to the data layer in a GA4-compatible format.

Example for purchase event: The purchase happens on the Thank you page, where checkout.liquid and the Additional scripts box no longer run. Load GTM as a custom pixel instead and push the purchase into its data layer from Shopify's customer events (Shopify's guide to a Google Tag Manager custom pixel). Then create a new Tag in GTM:

  • Tag Type: "Google Analytics: GA4 Event."
    • Configuration Tag: Select your "GA4 Configuration - All Pages" tag.
    • Event Name: purchase.
    • Event Parameters: Add parameters like transaction_id, value, currency, items, etc., mapping them to your data layer variables.
    • Triggering: Create a new Custom Event trigger that fires when event equals purchase (or whatever custom event name you're pushing to the data layer).
    • Name your tag (e.g., "GA4 Event - Purchase").
    • Click "Save."

Repeat this process for other critical ecommerce events (add_to_cart, view_item, begin_checkout, remove_from_cart, etc.), ensuring your data layer pushes the correct information for each event.

5. Test Your Setup:

In GTM, click "Preview."

Enter your Shopify store URL and click "Connect."

A new tab will open with your store, and a "Tag Assistant" window will appear.

Browse your store, add items to the cart, proceed to checkout, and complete a test purchase if possible.

Observe the "Tag Assistant" window to ensure your GA4 Configuration tag fires on all pages and your ecommerce event tags fire correctly when their respective actions are performed.

You can also check the "Realtime" report in your Google Analytics 4 property to see incoming data.

Important Considerations for Shopify Plus Merchants

checkout.liquid used to give Shopify Plus merchants direct control over checkout tracking, and other stores used the "Additional scripts" box on the Thank you page. Neither runs there anymore. Events like begin_checkout and purchase now come from pixels in the Customer events section of your Shopify admin: a custom pixel you add yourself, or an app pixel from a third-party app that provides GA4 data layer enhancements.

Verifying Your GA4 Data Collection

After setting up GA4 on your Shopify store, it is critical to verify that data is being collected accurately. Incorrect setup can lead to flawed insights and misguided marketing strategies.

1. Realtime Report: In your GA4 property, navigate to "Reports" > "Realtime." This report shows user activity on your site as it happens. You should see yourself (or test users) interacting with the store, and events firing as expected.

2. DebugView: The DebugView in GA4 is an invaluable tool for testing your setup.

In GTM, use the "Preview" mode.

In GA4, go to "Admin" > "DebugView."

As you navigate your store in preview mode, you will see a stream of events appearing in DebugView, along with their parameters. This allows for precise verification of each event's data payload.

3. Standard Reports: After 24-48 hours, check your standard GA4 reports (e.g., "Engagement," "Monetization") to ensure data populates correctly. Look at "Events" to see if your ecommerce events are registered and their counts are increasing.

Common GA4 Issues and Troubleshooting for Shopify

Even with careful setup, issues can arise. Here are common problems and their solutions:

No Data Appearing:

  • Measurement ID Check: Double-check that the Google & YouTube channel is connected to the right GA4 property, or that GTM uses the right Measurement ID (G-XXXXXXXXXX).
    • GTM Container Code: Ensure the GTM container snippets are correctly placed in theme.liquid (one in <head>, one in <body>).
    • Ad Blockers: Test with ad blockers disabled, as they can sometimes interfere with tracking.
    • Realtime vs. Standard Reports: Remember that standard GA4 reports can take 24-48 hours to process data, while Realtime is immediate.

Missing Ecommerce Events:

  • Data Layer Issues: The most common cause. Ensure your Shopify data layer is pushing the necessary ecommerce data in a GA4-compatible format. This often requires custom code or a specialized app.
    • GTM Tag Configuration: Verify that your GA4 event tags in GTM are correctly configured with the right event names, parameters, and triggers.
    • Trigger Misconfiguration: Ensure your GTM triggers for ecommerce events are firing at the correct time (e.g., a purchase event trigger should fire only on the order confirmation page).

Duplicate Data:

  • Multiple GA4 Tags: Check if you have multiple GA4 configuration tags or redundant event tags firing.
    • Redundant Data Layer Pushes: Ensure your custom code or app isn't pushing the same event data multiple times.

The Limitations of Data Collection: Beyond "What" to "Why"

While setting up Google Analytics 4 provides a reliable foundation for understanding "what" is happening on your Shopify store, it inherently stops short of explaining "why." GA4 excels at collecting event data: a user viewed a product, added it to their cart, or completed a purchase. It can even show you conversion rates, user paths, and segments.

Traditional analytics, including GA4, primarily offers correlational insights. It might tell you that users who view product X are more likely to purchase product Y, but it doesn't definitively explain the causal relationship. Is it because product X primes them for Y, or are there underlying factors influencing both? This distinction is important for effective decision-making. Relying solely on correlational data can lead to misinterpretations and suboptimal strategic adjustments. For instance, you might refine a page based on high engagement metrics, only to find that engagement doesn't translate to actual conversions because the underlying "why" was never addressed.

Consider the challenge of marketing attribution. GA4, like other analytics platforms, provides various attribution models (e.g., Last Click, Data-Driven). These models attempt to distribute credit for conversions across different touchpoints. However, even the most sophisticated data-driven models are still based on observed correlations and predefined rules, not true causality. They struggle to accurately account for the complex, non-linear ways in which marketing efforts truly influence purchasing decisions.

Ready to stop guessing and start knowing the true drivers of your ecommerce success?

Discover the Power of Causal Inference for Your Shopify Store

Frequently Asked Questions (FAQ)

Q1: Is Google Analytics 4 free to use?

A1: Yes, Google Analytics 4 is free to use for most businesses. It offers reliable features for data collection, reporting, and analysis without any direct cost. There are enterprise-level versions (like GA360) that offer higher data limits and advanced features, but the standard GA4 property is free.

Q2: Can I run both Universal Analytics and GA4 simultaneously on Shopify?

A2: While Universal Analytics has stopped processing new data, it was possible to run both UA and GA4 in parallel during the transition period. This is often referred to as "dual tagging." If you still have Universal Analytics code on your Shopify store, it won't be collecting new data, so focusing solely on your GA4 implementation is now the priority.

Q3: What is "Enhanced Measurement" in GA4 and should I enable it for Shopify?

A3: Enhanced Measurement is a feature in GA4 that automatically collects certain common events without requiring additional code. These include page views, scrolls, outbound clicks, site search, video engagement, and file downloads. It is highly recommended to keep Enhanced Measurement enabled for your Shopify store, as it provides a valuable baseline of user interaction data.

Q4: How do I track specific product variations (SKUs) in GA4 on Shopify?

A4: Tracking specific product variations or SKUs in GA4 requires ensuring that your ecommerce events (like view_item, add_to_cart, purchase) pass the correct item_id or item_variant parameters. If you're using Google Tag Manager, you'll need to ensure your data layer pushes this information, and your GA4 event tags are configured to capture these parameters. Shopify's default GA4 integration might have limitations

Data Integration Planning Template for Marketing Teams

Free Shopify Marketing KPI Dashboard Template (Google Sheets)

Free UTM Tracking Template for Shopify (Google Sheets)

Pricing from €99

Frequently asked questions

  • How much does accurate marketing attribution cost for Shopify stores?
    Pro is €299 a month, billed monthly, for continuous reads with lifetime look-back. The €99 read is refundable within 30 days, no questions asked. Prices exclude VAT.

Go deeper: Causal attribution, explained.

Sixty-second versions of these ideas: Causality Engine on YouTube Shorts.

Have an audience of ecommerce operators? Earn 20% recurring commission by recommending the €99 read.

Keep reading

Terms in this article

Browse the full glossary

Your platforms guess.
We run the math.

Upload a GA4 export and see what each channel caused, next to last-click, in 1–2 minutes. The read is yours to keep.

The free finding runs in your browser. Your file never leaves it. The full read is €99, refundable within 30 days, no questions asked. Prices exclude VAT.