Back to Guides
Guide
14 min read

How to Set Up Google Analytics 4 on Shopify

Google Analytics 4 is the standard for website analytics. This guide shows you how to set it up properly on Shopify with full ecommerce tracking so you can understand your customers and optimise your store.

Flex Commerce Team
Updated February 2024

Understanding GA4

Google Analytics 4 (GA4) represents a complete rebuild of Google's analytics platform. Unlike Universal Analytics (the previous version), GA4 is built around events rather than sessions. Everything a user does is tracked as an event, from page views to purchases.

This event-based model offers much more flexibility in what you can track and how you analyse user behaviour. For ecommerce stores, it means better insight into the customer journey from first visit to repeat purchase.

Key Differences from Universal Analytics

  • Event-based tracking - Everything is an event, not just button clicks
  • Cross-platform - Track users across web and app in one property
  • Privacy-focused - Built to work without cookies in the future
  • Machine learning - Predictive insights and anomaly detection built in

The learning curve for GA4 can be steep if you're used to Universal Analytics, but the capabilities are worth it. This guide will help you get set up correctly from the start.

Creating Your Property

Before connecting to Shopify, you need a GA4 property. If you already have one, skip to the next section. Here's how to create a new property:

  1. 1
    Go to Google Analytics

    Visit analytics.google.com and sign in with your Google account. If you don't have an Analytics account yet, click "Start measuring" to create one.

  2. 2
    Create a new property

    In Admin (gear icon), click "Create Property". Name it after your store. Select your reporting time zone and currency (GBP for UK stores).

  3. 3
    Describe your business

    Select your industry category (likely "Shopping") and business size. This helps Google provide relevant default reports.

  4. 4
    Choose your objectives

    Select "Generate leads" and "Drive online sales". This configures relevant default reports and suggested events.

  5. 5
    Set up a web data stream

    Select "Web" as your platform. Enter your Shopify store URL (your custom domain or myshopify.com domain). Name it something clear like "Website".

  6. 6
    Copy your Measurement ID

    After creating the stream, you'll see a Measurement ID starting with "G-" (e.g., G-ABC123XYZ). Copy this for the Shopify integration.

Pro Tip

Enable "Enhanced measurement" in your data stream settings. This automatically tracks scrolls, outbound clicks, site search, video engagement, and file downloads without any additional code.

Shopify Integration

Shopify has native GA4 integration that handles ecommerce tracking automatically. This is the recommended method as it tracks all standard ecommerce events without custom code.

Method 1: Shopify's Native Integration (Recommended)

  1. 1
    Go to Online Store settings

    In your Shopify admin, go to Online Store → Preferences. Scroll down to the Google Analytics section.

  2. 2
    Enter your Measurement ID

    Paste your G- Measurement ID from GA4. Shopify will validate it.

  3. 3
    Save your settings

    Click Save. The GA4 tracking code is now installed on all pages of your store, including checkout and order confirmation.

Method 2: Google Tag Manager (Advanced)

For more control over your tracking, you can use Google Tag Manager. This is useful if you want to add custom events or integrate multiple tracking platforms.

  1. 1.Create a GTM container at tagmanager.google.com
  2. 2.Add the GTM container code to your Shopify theme's head section
  3. 3.Create a GA4 Configuration tag with your Measurement ID
  4. 4.Set up ecommerce event tags using the data layer

Which Method Should You Use?

  • Native integration - Best for most stores. Simple, reliable, fully supported
  • GTM - Use if you need custom events, have multiple tracking pixels, or need server-side tagging

Ecommerce Tracking

GA4 has built-in ecommerce reports that show you everything from product views to purchase behaviour. When using Shopify's native integration, these events are tracked automatically.

Standard Ecommerce Events

Shopify's integration tracks these events out of the box:

view_item

Fires when a user views a product page. Includes product ID, name, price, and category information.

add_to_cart

Fires when a user adds a product to their cart. Tracks quantity and variant information.

begin_checkout

Fires when a user starts the checkout process. Shows how many visitors reach this stage.

purchase

Fires on order completion. Includes transaction ID, revenue, tax, shipping, and all purchased items.

Verifying Ecommerce Tracking

To confirm your ecommerce tracking is working:

  1. 1.Open GA4 and go to Reports → Realtime
  2. 2.In another tab, visit your store and view a product
  3. 3.Add the product to cart
  4. 4.In GA4 Realtime, you should see view_item and add_to_cart events
  5. 5.Complete a test purchase to verify the purchase event

Pro Tip

Use Google's DebugView (in GA4 Admin → DebugView) for detailed event inspection. It shows every parameter being sent with each event.

Key Events to Track

In GA4, "Key Events" (formerly called Conversions) are the actions that matter most to your business. You should mark important events as key events so they appear prominently in reports and can be used for Google Ads optimisation.

Setting Up Key Events

  1. 1.Go to GA4 Admin → Events
  2. 2.Find the event you want to mark (e.g., purchase)
  3. 3.Toggle "Mark as key event" to on

Recommended Key Events for Shopify

  • purchase - Your primary conversion event
  • add_to_cart - Shows buying intent
  • begin_checkout - High-intent micro-conversion
  • sign_up - If you have account registration
  • generate_lead - For newsletter signups

Creating Custom Events

You can create new events based on existing ones. For example, track when someone views a specific collection:

  1. 1.Go to Admin → Events → Create event
  2. 2.Name it (e.g., "view_sale_collection")
  3. 3.Set conditions: event_name equals "page_view" AND page_location contains "/collections/sale"

Custom Dimensions

Custom dimensions let you segment your data by attributes specific to your business. For ecommerce, these are incredibly valuable for understanding customer behaviour.

Useful Custom Dimensions for Shopify

  • Customer type - New vs returning customer
  • Logged in status - Guest vs account holder
  • Discount code used - Track which codes drive sales
  • Order count - First order vs repeat purchase

Setting Up Custom Dimensions

  1. 1.Go to Admin → Custom definitions → Custom dimensions
  2. 2.Click "Create custom dimension"
  3. 3.Enter a name and description
  4. 4.Select the scope (Event or User)
  5. 5.Enter the event parameter name that will contain the value

Pro Tip

You need to send the data before you can create the dimension. Use GTM or custom code to add parameters to your events, then create the matching custom dimension in GA4.

Reports and Insights

Once your tracking is set up, GA4 offers powerful reports to understand your store's performance. Here are the most valuable reports for ecommerce.

Ecommerce Purchases

Reports → Monetisation → Ecommerce purchases

Shows your best-selling products, revenue, and purchase quantity. Filter by date range to see trends.

Purchase Journey

Reports → Monetisation → Purchase journey

Visualises your funnel from session start to purchase. Shows where users drop off at each stage.

Traffic Acquisition

Reports → Acquisition → Traffic acquisition

See which channels (organic, paid, social, email) drive traffic and conversions. Essential for marketing ROI.

User Explorer

Explore → User Explorer

See individual user journeys through your site. Great for understanding how real customers behave.

Creating Custom Explorations

The Explore section lets you build custom reports. For ecommerce, try:

  • Funnel exploration - Custom conversion funnels
  • Path exploration - How users navigate your site
  • Segment overlap - Compare different user groups

Common Issues

GA4 setup can be tricky. Here are the issues we see most often and how to fix them.

No Data Appearing

If you've set up GA4 but see no data:

  • Check your Measurement ID is correct (starts with G-)
  • Wait 24-48 hours for data to process (standard reports have delay)
  • Check Realtime report first as it shows data immediately
  • Ensure ad blockers aren't blocking tracking on your test device

Duplicate Tracking

If you see doubled page views or events:

  • Check for GA4 code in both Shopify settings AND your theme
  • Look for GTM container that also has GA4 configured
  • Use one integration method only

Missing Purchase Data

If other events work but purchases don't track:

  • Verify checkout isn't using a third-party system
  • Complete a test purchase to verify (you can refund it)
  • Check that purchase is marked as a key event

Discrepancy with Shopify Reports

GA4 numbers don't match Shopify's reports:

  • This is normal due to ad blockers and privacy tools
  • GA4 typically shows 10-20% less data than actual
  • Use Shopify for source of truth on revenue, GA4 for behaviour analysis

Need Help With Analytics?

Our team can set up GA4, custom events, and dashboards so you have clear insight into your store's performance and marketing effectiveness.