How to Set Up E-commerce in Google Analytics
Selling products online but finding a big fat zero in the revenue column of your Google Analytics reports? You're not alone. By default, Google Analytics is great at tracking sessions and pageviews, but it doesn't automatically know when a sale happens on your site. This article walks you through exactly how to set up e-commerce tracking in Google Analytics 4 so you can finally connect your marketing efforts to actual sales revenue.
Why E-commerce Tracking is Essential
Before getting into the technical steps, it's worth remembering why you're doing this. Without e-commerce tracking, you're flying blind, relying on gut feelings to make decisions about marketing budgets, product promotions, and site design. Once it’s set up, you can answer foundational questions for growing your business:
- Which marketing channels actually drive sales? See exactly how much revenue your SEO, Google Ads, Facebook campaigns, and email newsletters are generating.
- What are your most popular products? Identify your bestsellers and discover which products are often purchased together.
- What is your website's conversion rate? Know the percentage of visitors who end up making a purchase.
- How do users behave before they buy? Understand the path customers take, from their first visit to their final checkout.
Setting this up transforms Google Analytics from a simple traffic report into a powerful business intelligence tool that tells you what’s working and what isn't.
Choose Your Path: Two Ways to Set Up E-commerce Tracking
There are two main ways to enable e-commerce tracking in GA4. The method you choose depends on your e-commerce platform and your technical comfort level.
1. Direct Integration (The Easiest Method): Many popular e-commerce platforms like Shopify and WooCommerce (with official plugins) have built-in integrations that handle the setup for you. If a native integration exists for your platform, this is almost always the best place to start. It involves just a few clicks and requires no code.
2. Google Tag Manager (The Most Flexible Method): If you have a custom-built store or your platform doesn't have a seamless GA4 integration, you'll need to use Google Tag Manager (GTM). While it involves more steps, it gives you complete control over your tracking and is the standard for modern analytics implementations. This guide will focus primarily on the GTM method, as it's the most universally applicable solution.
Free PDF · the crash course
AI Agents for Marketing Crash Course
Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.
Method 1: Quick Setup with Native Integrations
If you use a major platform, check their documentation first. Enabling e-commerce tracking is often as simple as pasting your GA4 Measurement ID into a settings field. Here’s a quick overview for the two most popular platforms:
- Shopify: Shopify has a native Google & YouTube app. You simply add the app to your store, connect your Google account, and select your GA4 property. Shopify automatically sets up a data layer and sends e-commerce events like
view_item,add_to_cart, andpurchaseto Google Analytics for you. - WooCommerce: Several third-party plugins can connect WooCommerce to GA4. Look for one that is well-reviewed and actively maintained. Installing and configuring one of these plugins will typically enable e-commerce event tracking with minimal manual effort.
If you use one of these platforms, give the direct integration a try first. If it doesn't meet your needs or you want more customization, you can always move to a GTM setup later.
Method 2: Step-by-Step E-commerce Setup with Google Tag Manager
This is the definitive guide for anyone with a custom store or for those who need more control than a native integration provides. We’ll walk through the process of sending purchase data from your website to GA4.
Step 1: Check E-commerce Reporting is Enabled in GA4
This sounds obvious, but GA4 is so new that there's no longer a toggle to "turn on" e-commerce tracking like there was in Universal Analytics. GA4 automatically processes e-commerce data as long as you send it in the correct format. The key is in sending the correct events, like purchase or add_to_cart, with the required parameters.
So, there's no button to click here. Just know that when you send properly formatted events, the monetization reports will start to populate automatically.
Step 2: Enable the Data Layer on Your Website
The most technical but most important part of this entire process is the "data layer." Think of it as a hidden messaging system on your website. When a customer buys something, your website's backend needs to push the details of that purchase (what they bought, how much it cost, the order ID, etc.) into the data layer. Google Tag Manager can then read this information and send it to Google Analytics.
For a purchase event, the data layer code pushed on your "Thank You" or order confirmation page should look something like this:
<script>
window.dataLayer = window.dataLayer || [],
window.dataLayer.push({
event: 'purchase',
ecommerce: {
transaction_id: '12345',
value: 99.99,
tax: 4.90,
shipping: 5.99,
currency: 'USD',
items: [{
item_id: 'SKU_ABC',
item_name: 'Classic T-Shirt',
price: 29.99,
quantity: 1
}, {
item_id: 'SKU_XYZ',
item_name: 'Baseball Cap',
price: 19.99,
quantity: 3
}]
}
}),
</script>How do you implement this? Your developer will need to modify your site's code to dynamically generate this script on the confirmation page after a successful purchase. If you use a platform like WordPress or Magento, there are plugins and extensions available that will generate the data layer for you, saving you from having to code it from scratch.
Step 3: Create Data Layer Variables in GTM
With the data layer in place, you now need to teach GTM how to read the information inside it. You do this by creating Variables.
- Log in to your Google Tag Manager account and navigate to the Variables section.
- Under User-Defined Variables, click New.
- Choose Data Layer Variable as the variable type.
- In the Data Layer Variable Name field, you'll enter the path to the data you want to capture. For GA4, you just need one main variable for the entire 'items' array.
- Save this variable. You will use this in your event tag. Google Ads E-commerce Event Tags can automatically read other fields like value and transaction_id from the data layer without needing separate variables, making setup much simpler than it used to be.
Step 4: Create a Trigger in GTM
Next, you need to tell GTM when to fire your tag. In this case, we want it to fire whenever a purchase event happens.
- Navigate to the Triggers section and click New.
- Name your trigger something clear, like
Event - purchase. - For the trigger type, choose Custom Event.
- In the Event name field, enter
purchase. This must match theeventname in your data layer script exactly. - Leave it set to fire on "All Custom Events."
- Save your trigger.
Free PDF · the crash course
AI Agents for Marketing Crash Course
Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.
Step 5: Create the GA4 Event Tag
Finally, we'll put it all together by creating the tag that sends the purchase data to Google Analytics.
- Navigate to the Tags section and click New.
- Name your tag something like
GA4 - Event - Purchase. - For the Tag Configuration, select Google Analytics: GA4 Event.
- For the Configuration Tag, select your main GA4 configuration tag (the one that fires on all pages). If you don't have one, you'll need to create it first using your GA4 Measurement ID.
- In the Event Name field, type
purchase. Again, this name is standardized by Google and should match exactly. - Expand the Event Parameters section. You will need to explicitly pass the
itemsarray here. - Next, under Triggering, select the
Event - purchasetrigger you created in Step 4. - Save the tag.
You're almost done! Once you've saved everything, remember to click the Submit button in the top right corner of GTM to publish your changes live.
Verifying Your E-commerce Setup
Don't just assume it's working. Proper testing is absolutely essential.
Using GTM Preview Mode
Before publishing, use GTM's Preview mode. This opens a debug window connected to your site.
- Make a test purchase on your website.
- In the debug window, look on the left-hand side for the
purchaseevent to appear. - Click on the
purchaseevent, and then click on yourGA4 - Event - Purchasetag. - Check that the tag status is "Fired." Inspect the values in the tag details to ensure your variables are capturing the correct product names, prices, and quantities from your test purchase.
Using GA4 DebugView
After confirming the tag fires in GTM, head over to your Google Analytics 4 property.
- Go to Admin > DebugView.
- While your GTM Preview session is still active, your actions should appear in this report in real-time.
- When you complete a test purchase, you should see the
purchaseevent show up in the timeline. Click on it to inspect the parameters and make sure GA4 is receiving all the data correctly, including item details and revenue.
If you see the data appearing correctly in both GTM Preview and GA4 DebugView, congratulations! Your e-commerce tracking is officially up and running.
Final Thoughts
Setting up e-commerce tracking in Google Analytics 4 is one of the highest-leverage activities you can undertake for your online store. Now that you have a direct line of sight from your marketing activities to your revenue, you're empowered to make smarter, data-driven decisions that will help grow your business.
As you get comfortable with your GA4 data, you'll find the next challenge is blending those insights with data from all your other tools, like ads platforms and your CRM. That's precisely why we built Graphed. We make it easy to connect Shopify, Google Analytics, social ads, and all your marketing sources in one place. You can then ask questions in simple language - like "show me revenue by campaign from Google Ads vs. Facebook Ads" - and get an instant, real-time dashboard without the complex setup analysis often requires.
Related Articles
Facebook Ads For Dental Practices: The Complete 2026 Strategy Guide
Learn how to effectively use facebook ads for dental practices to attract new patients to your dental practice. This comprehensive 2026 guide covers targeting, budgeting, creative strategies, and ROI expectations.
Test: Facebook Ads For Dentists 2026
Test excerpt
Facebook Ads for Landscapers: The Complete 2026 Strategy Guide
Learn how to run profitable Facebook ads for landscapers in 2026. This complete guide covers audience targeting, ad formats, budgeting, and optimization strategies to generate leads at $30-50 per lead.