Analytics · January 2025 · 7 min read

    GA4 + GTM Setup for eCommerce: A Developer's Guide

    Server-side tracking, enhanced eCommerce events, and attribution models, how I set up analytics that actually help store owners make revenue decisions.

    Data analytics charts and graphs on screen

    By Cristian Daron

    Most eCommerce stores have broken analytics. They're either missing critical events, double-counting conversions, or relying on out-of-date Universal Analytics setups. Here's the framework I use every time I set up GA4 and GTM.

    The Foundation: GA4 Data Streams

    Start with a clean GA4 property. Create a single web data stream for your store. Enable enhanced measurement for page views, scrolls, outbound clicks, and site search. Disable file downloads unless you sell digital products, it just adds noise.

    GTM Container Architecture

    I use a structured GTM container with clear naming conventions: tags are prefixed with the platform (GA4, Meta, TikTok), triggers are named by the event they fire on, and variables follow a consistent data layer schema. This makes debugging and handoff infinitely easier.

    Essential eCommerce Events

    The GA4 enhanced eCommerce event set you must track: view_item, add_to_cart, begin_checkout, add_shipping_info, add_payment_info, and purchase. Each event needs the proper items array with product ID, name, category, price, and quantity. Without these, your funnel reports are useless.

    Server-Side Tagging

    Client-side tracking loses data to ad blockers, used by 29.5% of internet users according to GWI data for Q2 2025, and to browser privacy features. Server-side GTM tagging routes events through your own domain, dramatically improving data accuracy. I deploy server-side containers on Google Cloud Run; Google's setup guide puts each server at about $45 a month and recommends at least two for production.

    Meta & TikTok Pixel Integration

    For paid media attribution, I implement Meta Pixel (via Conversions API for server-side) and TikTok Pixel alongside GA4. The trick is deduplication, each event needs a consistent event_id that both client-side and server-side implementations share. Without deduplication, the same purchase is counted twice.

    Revenue Attribution Models

    GA4 defaults to data-driven attribution, which is fine for most stores. But for paid media-heavy businesses, I recommend also tracking last-click and first-click models in parallel. This gives store owners a complete picture: which channels introduce customers (first-click) vs. which close the sale (last-click).

    Debugging & Validation

    Before going live, validate every event using GA4 DebugView and GTM Preview mode simultaneously. Check: event names match exact GA4 specs, currency and value parameters are present on all monetary events, the items array is properly formatted, and no PII (emails, phone numbers) is being sent to GA4.

    Custom Dashboards

    Raw GA4 reports are overwhelming for store owners. I build Looker Studio dashboards with 4 key views: revenue overview (daily/weekly/monthly), funnel analysis (drop-off by step), product performance (top sellers, conversion by product), and traffic source ROI (revenue per channel).

    Sources

    1. Google Analytics, Measure ecommerce (GA4 events) (opens in a new tab)
    2. Google, Server-side Tag Manager: Cloud Run setup guide (opens in a new tab)
    3. Meta for Developers, Deduplicate Pixel and server events (opens in a new tab)
    4. Backlinko, Ad Blocker Usage and Demographic Statistics (GWI data, Q2 2025) (opens in a new tab)