If you run an ecommerce store and you are not tracking purchases, checkout behaviour, and product interactions properly, you are making decisions in the dark. Google Analytics 4 (GA4) combined with Google Tag Manager (GTM) gives you the infrastructure to collect meaningful conversion data, understand where your revenue comes from, and feed your ad campaigns with high-signal events.
This guide walks through a complete GA4 + GTM setup for ecommerce. It covers property creation, tag configuration, enhanced ecommerce events, purchase tracking, and conversion event setup for Google Ads and other platforms. Every section is written for developers, store owners, and technical marketers who want a working setup — not theoretical explanations.
Why GA4 and GTM Matter for Ecommerce in 2026
Universal Analytics stopped processing data in July 2023, and GA4 is now the only Google Analytics platform. Unlike UA, GA4 uses an event-based data model instead of session-based tracking. This shift matters for ecommerce because it gives you more flexibility to define what a conversion looks like, how you attribute revenue, and how you send data to ad platforms.
Google Tag Manager sits between your storefront and GA4. Instead of hardcoding analytics snippets into your theme files, GTM lets you deploy tracking tags, triggers, and variables through a web interface. This means you can update your tracking without touching code, reduce the risk of breaking your store, and maintain a clean separation between business logic and analytics.
Here is what a proper setup unlocks:
- Purchase tracking — Know exactly how much revenue each marketing channel generates
- Checkout behaviour analysis — See where customers drop off between cart and purchase
- Product performance data — Track views, add-to-carts, and remove-from-carts per product
- Ad campaign optimisation — Feed conversion data back to Google Ads, Meta, and other platforms
- Server-side tracking readiness — A well-structured GTM setup makes migrating to server-side tagging much simpler
Step 1: Create Your GA4 Property
Before you configure any tags, you need a GA4 property that is ready to receive ecommerce data.
1.1 Create the property
Go to the Google Analytics admin panel. Click Create Property and choose a property name that matches your store. Make sure you select the right timezone and currency — these cannot be changed later without creating a new property.
1.2 Enable enhanced measurement
In your GA4 property, go to Admin > Data Streams > Web. Under Enhanced Measurement, toggle on Page views, Scrolls, Outbound clicks, Site search, Video engagement, and File downloads. These give you baseline engagement data without any extra code.
1.3 Enable ecommerce reporting
In the GA4 admin panel, go to Admin > Ecommerce settings. Toggle Enable Ecommerce to on. This tells GA4 to expect ecommerce event parameters. Without this toggle, your purchase and product interaction events will still arrive but will not appear in the ecommerce reports.
1.4 Note your measurement ID
Your measurement ID looks like G-XXXXXXXXXX. You will need this when configuring the GA4 tag in GTM. Find it under Admin > Data Streams > Your Web Stream.
Step 2: Set Up Google Tag Manager Container
With your GA4 property ready, the next step is creating a GTM container and connecting it to your store.
2.1 Create a GTM account and container
Go to Google Tag Manager and create a new account if you do not have one. Within the account, create a container for your ecommerce store. Choose Web as the target platform. Your container ID will look like GTM-XXXXXXX.
2.2 Install GTM on your store
Google Tag Manager provides two code snippets. The first goes in the <head> of every page on your store. The second goes immediately after the opening <body> tag. If you are using Shopify, add the head snippet to theme.liquid just before </head>, and the body snippet just after <body>. For WooCommerce, use a plugin like GTM4WP or add the snippets to your theme's header.php and footer.php. For custom Laravel or React stores, include the snippets in your main layout template.
2.3 Set up the GA4 configuration tag
In GTM, create a new tag:
- Tag type: Google Analytics: GA4 Configuration
- Measurement ID: Your
G-XXXXXXXXXXID - Trigger: All Pages (initialisation — All Pages trigger type)
Name this tag GA4 - Configuration and save it. Then submit your container and publish. Within a few hours, GA4 should start showing real-time page view data.
Step 3: Configure Enhanced Ecommerce Events
GA4 supports a standard set of ecommerce events that give you granular insight into how users interact with your products. These events must be pushed to the dataLayer before GTM can forward them to GA4.
3.1 What the dataLayer needs to look like
The dataLayer is a JavaScript array that GTM reads to extract event data. Each ecommerce event follows a standard structure:
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: "add_to_cart",
ecommerce: {
currency: "USD",
value: 29.99,
items: [
{
item_id: "SKU-001",
item_name: "Product Name",
price: 29.99,
quantity: 1,
item_category: "Category Name"
}
]
}
});
3.2 Key ecommerce events to implement
GA4 recognises these standard ecommerce events:
- view_item — Fired when a user views a product detail page. Include the product ID, name, price, and category.
- add_to_cart — Fired when a user adds a product to their cart. Include the item and quantity.
- remove_from_cart — Fired when a user removes a product from their cart.
- view_cart — Fired when a user views their cart page.
- begin_checkout — Fired when a user starts the checkout process.
- add_payment_info — Fired when a user selects a payment method during checkout.
- add_shipping_info — Fired when a user enters their shipping details.
- purchase — Fired when a transaction is completed. This is your most important event.
3.3 Create GTM tags for each event
For each ecommerce event, create a GA4 Event tag in GTM:
- Tag type: Google Analytics: GA4 Event
- Configuration Tag: Select your GA4 Configuration tag
- Event Name: Use the GA4 event name (e.g.,
view_item,add_to_cart) - Event Parameters: Enable Send Ecommerce Data — this tells the tag to read the
ecommerceobject from the dataLayer - Trigger: Create a Custom Event trigger that matches the dataLayer event name (e.g.,
add_to_cart)
Repeat this for every ecommerce event you want to track. It is worth implementing all standard events from the start so you have historical data if you need it later.
Step 4: Track Purchases and Revenue
The purchase event is the single most important conversion event for any ecommerce store. This is what tells GA4 that revenue was generated, and it is the event most ad platforms need to optimise for purchases.
4.1 Purchase dataLayer structure
The purchase event should fire on the order confirmation or thank-you page — never on the cart or checkout page. The dataLayer push should look like this:
window.dataLayer.push({
event: "purchase",
ecommerce: {
transaction_id: "ORD-20260701-001",
affiliation: "Online Store",
value: 149.95,
tax: 12.00,
shipping: 5.99,
currency: "USD",
coupon: "WELCOME10",
items: [
{
item_id: "SKU-045",
item_name: "Premium Widget",
price: 49.99,
quantity: 2,
item_category: "Widgets"
},
{
item_id: "SKU-102",
item_name: "Widget Accessory Pack",
price: 29.99,
quantity: 1,
item_category: "Accessories"
}
]
}
});
4.2 Important requirements
- transaction_id must be unique for every purchase. If a user refreshes the confirmation page, GA4 uses the transaction ID to deduplicate the purchase event. Without a unique ID, the same purchase may be counted multiple times.
- currency must be a valid ISO 4217 currency code (USD, EUR, GBP, etc.).
- value should be the total transaction value including tax and shipping.
- Each item object must include
item_id(oritem_name) — these are the minimum required fields.
4.3 GTM tag for purchase
Create a GA4 Event tag with event name purchase. Enable Send Ecommerce Data. Set the trigger to a Custom Event trigger matching purchase. Make sure the purchase dataLayer push fires before the GTM page view tag. The recommended approach is to push the data in the <head> of your confirmation page, above the GTM container snippet.
Step 5: Set Up Conversion Events for Ad Campaigns
Tracking events inside GA4 is useful for analysis, but to optimise ad campaigns you need to mark specific events as conversions and connect them to Google Ads, Meta, or other platforms.
5.1 Mark events as conversions in GA4
In your GA4 property, go to Admin > Conversions. Click New Conversion Event and enter the event name — for example purchase, add_to_cart, or begin_checkout. GA4 will start recording these as conversions. You can also mark events directly by naming them purchase in the GTM tag — GA4 auto-detects several standard ecommerce events as conversions.
5.2 Link GA4 to Google Ads
In GA4, go to Admin > Product Links > Google Ads Links. Link your Google Ads account. Once linked, GA4 conversion events become available in Google Ads as conversion actions. You can then use them for Smart Bidding, which automatically adjusts bids to maximise conversions.
5.3 Set up conversion tracking for other platforms
For Meta (Facebook) Ads, use the Meta Pixel or Conversions API (CAPI) alongside your GA4 setup. Push the same purchase data to both GA4 and Meta — either through separate GTM tags or via server-side calls. For TikTok, Pinterest, and other platforms, the approach is similar: add their respective GTM tag templates or custom HTML tags that read the same dataLayer.
5.4 Enhanced conversions for better match rates
Google Ads offers enhanced conversions, which send hashed first-party customer data (email, phone) alongside your conversion events to improve match rates. In GA4, enable enhanced conversions under Admin > Data Streams > Your Web Stream > Enhanced Conversions. You will need to populate the user-provided data in the dataLayer:
window.dataLayer.push({
event: "purchase",
ecommerce: { /* ... */ },
user_data: {
email: "customer@example.com",
phone: "+1234567890",
first_name: "John",
last_name: "Doe"
}
});
Then configure your GA4 tag in GTM to read the user_data object using a Custom JavaScript variable.
Testing and Debugging Your Setup
Before any tracking configuration goes live, you must test it thoroughly. Incorrect tracking data is worse than no tracking data because it leads to bad optimisation decisions.
Use GTM Preview mode
In GTM, click the Preview button. This opens a debug environment where you can see which tags fire on each page interaction. Visit your store, add a product to cart, go through checkout, and complete a purchase. Check that each ecommerce event fires at the expected step and contains the correct parameters.
Use the GA4 DebugView
In GA4, go to Admin > DebugView. This shows events from devices that have the debug mode enabled. To enable debug mode, either use the Google Analytics Debugger Chrome extension or set the debug_mode parameter to true in your GA4 configuration tag.
Validate the dataLayer on each page
Use the browser console and type dataLayer to inspect the current state of the dataLayer. For each page, verify that the ecommerce object contains the expected fields. For the purchase page, confirm that the transaction ID is present and unique.
Common debugging checklist
- Does the purchase event fire on the confirmation page only (not cart or checkout)?
- Is the
transaction_idunique per purchase? - Are currency codes in ISO 4217 format?
- Do item IDs match your product SKUs consistently across all events?
- Is the dataLayer push happening before GTM loads on the page?
Common Mistakes to Avoid
After setting up GA4 + GTM for dozens of ecommerce stores, these are the most frequent issues we see:
Duplicate purchase events
If a user refreshes the order confirmation page without a unique transaction_id, GA4 records a second purchase. Always pass a unique transaction ID and let GA4 handle deduplication automatically.
Firing purchase event on the wrong page
The purchase event must only fire on the order confirmation or thank-you page. If it also fires on the cart or checkout page, your conversion numbers will be inflated and your ad campaign optimisation will be broken.
Missing currency field
GA4 requires the currency field at the top level of the ecommerce object. Without it, purchase revenue may not appear correctly in reports. Always include currency in every ecommerce event, not just purchases.
Inconsistent item IDs
If your item_id values differ between view_item, add_to_cart, and purchase events, GA4 treats them as different products. Use the same SKU or product ID consistently across every event type.
Cannot see GTM preview
If GTM Preview mode does not load correctly, check that your GTM snippet is in the <head> and not inside a delayed-load script. GTM Preview injects a debug toolbar that requires the container to load synchronously.
Not testing on mobile
Many store owners test their tracking only on desktop. Mobile traffic often accounts for 60-80% of ecommerce visits. Test every event on mobile devices, including add-to-cart and purchase flows.
Next Steps: Get Professional GA4 + GTM Setup
A correctly configured GA4 + GTM setup is the foundation of data-driven ecommerce. Without it, you cannot accurately measure ROI, optimise ad spend, or understand customer behaviour. The difference between a store with proper tracking and one without is the difference between making informed decisions and guessing.
If you need help setting up GA4, GTM, and conversion tracking for your ecommerce store, DevNuro can handle the entire configuration — from dataLayer design to Google Ads integration. We work with Shopify, WooCommerce, Laravel, Webflow, and custom-built stores.
Related services from DevNuro