Ecommerce
How do you set up ecommerce tracking in GA4?
GA4 ecommerce tracking requires pushing structured events (`view_item`, `add_to_cart`, `begin_checkout`, `purchase`) with product parameters to the data layer on each page. Implement it through Google Tag Manager by creating a data layer push for each ecommerce event, then mapping those to GA4 event tags. The purchase event must include `transaction_id`, `value`, `currency`, and an `items` array with product details.
Key Considerations
- Use Google Tag Manager's data layer — don't fire GA4 events inline; GTM gives you control, debugging, and version history
- Implement the full funnel: `view_item` → `add_to_cart` → `begin_checkout` → `add_shipping_info` → `add_payment_info` → `purchase`
- The `items` array must include `item_id`, `item_name`, `price`, and `quantity` at minimum for meaningful reporting
- Validate with GA4 DebugView (real-time event stream) and GTM Preview Mode before going live
- Server-side GTM improves data accuracy by 15–30% compared to client-side-only tracking due to ad blockers and browser restrictions