How to Set Up Ecommerce Tracking in Google Analytics 4

Cody Schneider8 min read

Tracking what your customers do on your website is fundamental to growing your online business. Without accurate data, you're just guessing at what works. This is where Google Analytics 4 comes in, but getting its powerful ecommerce tracking set up correctly can feel like a maze. This guide clears up the confusion and gives you a step-by-step path to start collecting the sales data you need to make smarter marketing decisions.

GraphedGraphed

Still Building Reports Manually?

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

Watch Graphed demo video

Why Bother with GA4 Ecommerce Tracking?

Setting this up isn't just a technical exercise, it's about unlocking crucial business insights. When you properly track ecommerce activity, you can finally connect your marketing efforts directly to revenue. You'll be able to answer questions like:

  • Which marketing channels (Organic Search, Paid Social, Email) are driving the most sales?
  • What is the conversion rate of my most popular products?
  • Where are customers dropping off in the checkout process?
  • What is the average order value from visitors who came from our latest Facebook ad campaign?
  • How much revenue did our last blog post generate?

This data moves you from making decisions based on hunches to making them based on cold, hard facts. It's the difference between hoping for growth and building a strategy to achieve it.

Understanding the Core Concepts: Events and Parameters

Before jumping into the setup, it helps to understand how GA4 thinks about ecommerce. Unlike its predecessor (Universal Analytics), GA4 is entirely event-based. Every user interaction is captured as an "event."

For ecommerce, Google has a set of recommended standard events. These include:

  • view_item: A user views a product detail page.
  • add_to_cart: A user adds a product to their shopping cart.
  • begin_checkout: A user starts the checkout process.
  • purchase: A user completes a purchase.

Each event is sent with additional information, called "parameters," which provide the critical details. For a purchase event, the parameters would include things like transaction_id, currency, value (total revenue), and items (an array of the products purchased).

Your job is to make sure your website sends these specific events with their required parameters to Google Analytics at the right time. How you do this depends on what platform your store is built on.

GraphedGraphed

Still Building Reports Manually?

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

Watch Graphed demo video

Option 1: The Easy Way (Shopify and WooCommerce Integrations)

If you're using a major ecommerce platform, you're in luck. Most have built-in integrations or well-supported plugins that handle all the tricky coding for you. This is the fastest and most reliable path for most store owners.

For Shopify Stores

Shopify's native Google Analytics integration is typically the simplest way to get up and running. It automatically sets up your GA4 tag and sends the necessary ecommerce events.

  1. From your Shopify admin, go to Online Store > Preferences.
  2. In the "Google Analytics" section, click Manage pixel here. This might redirect you to the "Google & YouTube" app within Shopify.
  3. Connect your Google Account and select your GA4 Property Measurement ID (it looks like G-XXXXXXXXXX).
  4. Once connected, Shopify automatically begins sending ecommerce data like product views, adds to cart, and purchases to GA4. It manages the data layer and event firing behind the scenes.

A note on checkout funnels: Because Shopify controls the checkout pages, getting detailed checkout step data can sometimes be challenging with the native integration. However, the essential begin_checkout and purchase events are reliably tracked.

For WooCommerce Stores (WordPress)

For those running a WordPress site with WooCommerce, several plugins can bridge the gap. While you could attempt a manual setup, using a dedicated plugin saves a ton of time and prevents errors.

One of the most popular and effective solutions is the Google Analytics 4 for WordPress by GTM4WP plugin.

  1. Install and activate the GTM4WP plugin from your WordPress dashboard.
  2. In your WordPress admin, go to Settings > Google Tag Manager.
  3. In the "General" tab, enter your Google Tag Manager Container ID. (We'll cover GTM in the next section, but the plugin uses it to inject the necessary tracking codes).
  4. Go to the "Integration" > "WooCommerce" tab within the plugin settings.
  5. Check the box for "Track classic ecommerce" and "Track enhanced ecommerce." Even though the naming is from the old Universal Analytics, the plugin uses it to enable sending GA4-compatible ecommerce event data.
  6. Save your changes. The plugin will now automatically generate the required data layer and fire the GA4 ecommerce events for product views, cart actions, checkouts, and purchases.

Using a plugin like this is highly recommended for WooCommerce because it correctly formats all the product data and pushes it into the data layer, which is the most difficult part of a manual setup.

Option 2: The Manual Method (Google Tag Manager)

If you have a custom-built store or are using a platform without a simple integration, you'll need to roll up your sleeves with Google Tag Manager (GTM). This approach provides maximum flexibility but requires more technical work.

The goal here is to manually implement a "data layer" - a behind-the-scenes JavaScript object that holds all the product and transaction data - and then configure GTM to read that data and send it to GA4.

GraphedGraphed

Still Building Reports Manually?

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

Watch Graphed demo video

Step 1: Get the Data Layer Working

This is the most critical and challenging step. Your developer will need to write code that sends detailed ecommerce information to the data layer whenever a key action occurs. For example, when a customer completes a purchase, your website needs to push code snippet to the data layer that looks something like this:

window.dataLayer = window.dataLayer || [],
window.dataLayer.push({
  event: 'purchase',
  ecommerce: {
    transaction_id: 'ORDER-12345',
    affiliation: 'My Cool Store',
    value: 142.35,
    tax: 10.00,
    shipping: 5.00,
    currency: 'USD',
    items: [{
      item_id: 'SKU-001',
      item_name: 'Classic Blue T-Shirt',
      item_category: 'Apparel',
      price: 49.95,
      quantity: 1
    },{
      item_id: 'SKU-002',
      item_name: 'Denim Jeans',
      item_category: 'Apparel',
      price: 77.40,
      quantity: 1
    }]
  }
}),

You need to create similar data layer pushes for view_item, add_to_cart, begin_checkout, and any other events you want to track. The structure and naming are very important and must match Google's documented specifications.

Step 2: Set up Variables, Triggers, and Tags in GTM

Once the data layer is successfully implemented, you can set up GTM to capture and use that information.

Triggers: Your Triggers tell GTM when to fire a tag. You will create a "Custom Event" trigger for each of the ecommerce events in your data layer. For instance, you'll create one named "Event - purchase" that listens for the event name purchase from the data layer snippet above.

Variables: You then need to create "Data Layer Variable" types in GTM to pull specific information out of the data layer. You would create variables for ecommerce.transaction_id, ecommerce.value, ecommerce.currency, and so on.

GA4 Event Tag: Finally, you'll create a Google Analytics: GA4 Event Tag.

  • Choose your main GA4 Configuration Tag.
  • For the "Event Name," you can dynamically pull it from the data layer. It's common practice to use {{Event}}, which is a built-in GTM variable that captures the event key from your data layer push.
  • Under "Event Parameters," you'll map the data from your data layer to the parameters GA4 expects. For your purchase event, you'd add rows like:

You'll attach your Event - purchase Custom Event Trigger to this tag. This tells GTM: "When you hear the 'purchase' event from the website, grab all this data from the data layer and send it to GA4 using this tag." You'll repeat this process for all your other ecommerce events.

GraphedGraphed

Still Building Reports Manually?

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

Watch Graphed demo video

How to Verify Your Tracking is Working

Setting this all up without checking your work is a recipe for disaster. Luckily, there are excellent tools to verify everything is firing correctly.

  1. Google Tag Manager Preview Mode: This is your best friend during a manual setup. It lets you browse your live site in a debug window, showing you exactly which tags are firing on each page and what data is being sent. You can click "add to cart" and see the corresponding tag fire with all the correct product information.
  2. GA4 DebugView: In your GA4 property, navigate to Admin > DebugView. This provides a real-time stream of all events coming from your browser (when in GTM Preview mode). You can see ecommerce events like purchase appear instantly and inspect the parameters being collected by Google Analytics to confirm they are correct.

Use both tools. First, confirm GTM is firing the tag correctly, then confirm that GA4 is receiving it correctly.

Final Thoughts

Properly setting up GA4 ecommerce tracking is a powerful first step toward making data-driven decisions that can genuinely grow your business. It allows you to move beyond simple traffic metrics and truly understand how your customers interact with your products and what ultimately drives them to make a purchase.

While having this data in GA4 is essential, it's often just one piece of a much larger puzzle. Many businesses struggle because their ad performance is in Facebook Ads, their sales data is in Shopify, and their web traffic is in Google Analytics — all in separate tabs. We built Graphed to solve this very problem. By connecting all your data sources in one place, you can skip the exporting and spreadsheet hassle and just ask questions in plain English, like "Show me my top-performing Facebook campaigns by Shopify revenue," and get an instant real-time dashboard. This lets you focus on finding insights, not just collecting data.

Related Articles

How to Enable Data Analysis in Excel

Enable Excel's hidden data analysis tools with our step-by-step guide. Uncover trends, make forecasts, and turn raw numbers into actionable insights today!