How to Enable Ecommerce Tracking in Google Analytics 4

Cody Schneider9 min read

Setting up eCommerce tracking in Google Analytics 4 isn’t automatic, which often surprises new users who expect it to work out of the box. Without it, you’re missing the most critical data for your online store: what people are buying, how much they're spending, and which channels are actually driving revenue. This guide will walk you through exactly how to enable eCommerce tracking in GA4, whether you’re using a popular platform like Shopify or need a more custom setup.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Why Set Up GA4 eCommerce Tracking?

Before diving into the "how," it’s important to understand the "why." Standard GA4 tracking tells you about user behavior - like page views, sessions, and clicks. But eCommerce tracking connects that behavior to actual business results. It unlocks a new set of reports and data focused entirely on sales performance.

Once enabled, you can answer essential questions like:

  • What are my top-selling products? See which products are most popular by revenue and units sold.
  • Which marketing campaigns are generating the most sales? Move beyond traffic and measure the real ROI of your ads and content.
  • Where do users drop off in the checkout process? Identify friction points in your funnel, from viewing a product to adding it to the cart and finally purchasing.
  • What is the average order value? Track how purchase value changes over time or by traffic source.

GA4 captures this information through specific eCommerce events, such as view_item, add_to_cart, begin_checkout, and purchase. Getting these events to fire correctly is the key to unlocking powerful monetization reports.

The Two Paths to Enabling eCommerce Tracking

There are two main ways to get your sales data flowing into Google Analytics 4. The right path for you depends on what platform your website is built on and your technical comfort level.

  1. Platform Integration or Plugin: This is the easiest and most common method. Platforms like Shopify or eCommerce plugins for WordPress (like WooCommerce) have built-in integrations or partners that handle all the complex coding for you. You typically just need to add your GA4 Measurement ID, and the platform does the rest. This is the recommended route for most users.
  2. Manual Setup with Google Tag Manager: This method offers the most flexibility but requires technical work. You or your developer will need to implement a "data layer" on your website and configure tags in Google Tag Manager to grab the eCommerce data and send it to GA4. This is ideal for custom-built websites or when a pre-built integration isn’t available.

We’ll cover both methods in detail below.

Method 1: Using a Platform Integration (The Easy Way)

If you're using a major eCommerce platform, chances are there's a simple, official way to connect it to GA4. Here’s how to do it for two of the most popular options.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

For Shopify Stores

Shopify makes this process incredibly simple through its native Google & YouTube app. This app automatically sets up GA4 and fires the essential eCommerce events, requiring no code from you.

  1. Install the Google & YouTube App: From your Shopify admin dashboard, go to Apps, search for "Google & YouTube," and install the official app.
  2. Connect Your Google Account: During the setup process, you'll be prompted to connect the Google account that has access to your Google Analytics property.
  3. Select Your GA4 Property: The app will automatically detect your available GA4 properties. Simply choose the correct one from the dropdown list. Your Measurement ID (which looks like G-XXXXXXXXXX) will be connected.

That’s it. Once connected, Shopify automatically sends page_view, view_item, add_to_cart, begin_checkout, and purchase data to your GA4 property whenever those actions occur on your store. Your sales data will start appearing in GA4 reports within 24-48 hours.

For WooCommerce (WordPress) Stores

For websites built on WordPress with WooCommerce, the setup is handled by a plugin. You have several options, but one of the most reliable is the official Google Listings & Ads plugin or a dedicated integration plugin like GTM4WP (Google Tag Manager for WordPress).

Using the official Google Listings & Ads plugin:

  1. Install the Plugin: In your WordPress dashboard, navigate to Plugins → Add New. Search for "Google Listings & Ads" and install and activate it.
  2. Connect Your Accounts: Follow the on-screen prompts to connect your WordPress site to your Google Merchant Center and Google Ads accounts. During this flow, you will also connect your Google Analytics account.
  3. Confirm GA4 is Connected: The plugin will place the necessary tracking code on your site. It handles passing product data, cart information, and purchase details into the data layer and sending it to GA4.

This method correctly implements the key eCommerce events and ensures your product data aligns with what's in your Google Merchant Center, which is great for running Performance Max campaigns.

Method 2: Manual Setup with Google Tag Manager

If your store is on a custom platform or your integration isn't sending all the data you need, Google Tag Manager (GTM) is your answer. This process is more involved because you have to manually tell GTM exactly what data to look for and where to send it.

This method relies on a concept called the Data Layer.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

What is a Data Layer?

Think of the data layer as a behind-the-scenes messaging system on your website. When a customer adds a product to their cart, your website's code should "push" a message to this data layer containing all the relevant details: product ID, name, price, quantity, etc.

Google Tag Manager is constantly listening to this data layer. When it sees an eCommerce message appear, it grabs that information and structures it in a way Google Analytics can understand.

Your developer needs to add the code that pushes this information to the data layer. Here are examples of what the data layer code looks like for key eCommerce actions, following Google's recommended format.

Example: view_item event

This should fire when a user views a product detail page.

window.dataLayer = window.dataLayer || [],
window.dataLayer.push({
  event: 'view_item',
  ecommerce: {
    currency: 'USD',
    value: 19.99,
    items: [
      {
        item_id: 'SKU12345',
        item_name: 'Classic T-Shirt',
        item_category: 'Apparel',
        price: 19.99,
        quantity: 1
      }
    ]
  }
}),

Example: add_to_cart event

This should fire when a user clicks the "Add to Cart" button.

window.dataLayer = window.dataLayer || [],
window.dataLayer.push({
  event: 'add_to_cart',
  ecommerce: {
    currency: 'USD',
    value: 39.98,
    items: [
      {
        item_id: 'SKU12345',
        item_name: 'Classic T-Shirt',
        item_brand: 'YourBrand',
        item_variant: 'Blue',
        price: 19.99,
        quantity: 2
      }
    ]
  }
}),

Example: purchase event

This should fire on the "Thank You" or order confirmation page.

window.dataLayer = window.dataLayer || [],
window.dataLayer.push({
  event: 'purchase',
  ecommerce: {
    transaction_id: 'T_12345',
    value: 57.97,
    tax: 3.00,
    shipping: 5.00,
    currency: 'USD',
    coupon: 'SUMMERSALE',
    items: [
      {
        item_id: 'SKU12345',
        item_name: 'Classic T-Shirt',
        price: 19.99,
        quantity: 2
      },
      {
        item_id: 'SKU67890',
        item_name: 'Stylish Cap',
        price: 14.99,
        quantity: 1
      }
    ]
  }
}),
GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Setting Up GTM Tags, Triggers, and Variables

Once your developer has the data layer firing correctly, you can set up GTM.

  1. Create Variables: In GTM, navigate to Variables. You need to create "Data Layer Variable" types to capture the eCommerce data. For example, create a variable named ecommerce.items to capture the items array, another named ecommerce.transaction_id for the transaction ID, and so on.
  2. Create a Trigger: Go to Triggers and create a new "Custom Event" trigger. Set the Event Name to match the event in your data layer (e.g., purchase). This trigger tells GTM: "When you see the 'purchase' event in the data layer, fire any tag associated with me."
  3. Create the Tag: Go to Tags and create a new "Google Analytics: GA4 Event" tag.

You’ll need to repeat this process for each eCommerce event you want to track (add_to_cart, begin_checkout, etc.). It’s a meticulous process, but it gives you complete control over your data.

How to Verify Your eCommerce Tracking is Working

Regardless of which method you use, verifying your setup is crucial. Don't just assume it's working.

Use GA4's DebugView

The best way to test in real-time is with GTM's Preview mode and GA4's DebugView.

  1. In GTM, click the Preview button in the top right, enter your website URL, and connect.
  2. Your site will open in a new tab with the GTM debug panel. Perform an eCommerce action, like adding a product to the cart. You should see the add_to_cart event fire in the debug panel's summary list.
  3. In a separate tab, open GA4 and navigate to Admin → DebugView.
  4. You will see a live stream of events from your browser. When you perform the eCommerce action, you should see the event name (e.g., add_to_cart) appear in the timeline.
  5. Click on that event in DebugView. Check that the parameters, especially the items array, value, and currency, are all populated correctly. This confirms the data is arriving in GA4 as expected.

Check the Reports

After 24-48 hours, the data will begin to populate in your standard GA4 reports.

Navigate to Reports → Monetization. The two key reports to check are:

  • Monetization overview: This dashboard will show you high-level metrics like total revenue, number of purchases, and top-selling items. If you see data here, you’re on the right track.
  • Ecommerce purchases: This report gives you a detailed breakdown of revenue by item ID and item name.

Final Thoughts

Enabling eCommerce tracking turns Google Analytics from a general website traffic tool into a powerful sales analysis platform. Whether you use a simple one-click integration from Shopify or a detailed Google Tag Manager implementation, getting this data flowing is a non-negotiable step for any serious online store that wants to grow.

While gathering accurate eCommerce data in GA4 is essential, the real work begins when you have to analyze that data to find actionable insights. Instead of spending hours jumping between different reports in Google Analytics, HubSpot, Shopify, and your ad platforms, we built Graphed to simplify the entire process. You can connect all your data sources in seconds and ask questions in plain English, like "Show me my top-selling products by traffic source this month," and instantly get back a real-time dashboard. We automate the manual reporting work so you can focus on making decisions, not wrangling data.

Related Articles