Ecommerce Data Layer Generator
Generate complete ecommerce data layer code for GA4 and GTM
Build a full ecommerce data layer implementation from a simple form. Choose your event type, add products, and get production-ready code for GA4 via GTM โ including all required and recommended parameters.
How It Works
Choose your event type
Select from purchase, add_to_cart, view_item, begin_checkout, or view_item_list.
Fill in transaction & product details
Add currency, value, transaction ID, and one or more product objects.
Copy your data layer code
Get the complete window.dataLayer.push() snippet ready to add to your website.
Frequently Asked Questions
The Complete GA4 Ecommerce Data Layer: What You Need to Know
The GA4 ecommerce data layer is a standardised JavaScript object pushed to window.dataLayer before GTM fires any ecommerce tags. It tells GA4 (via GTM) what happened in the user's shopping journey โ what products they viewed, added to cart, and purchased โ along with all the financial and product metadata needed for accurate revenue attribution and Smart Bidding. This ecommerce data layer generator produces production-ready data layer code for any GA4 ecommerce event with all required and recommended fields pre-populated.
GA4 Ecommerce Events: What to Implement and When
GA4 defines eleven standard ecommerce events that map to the customer purchase journey. You don't need all eleven โ implement the ones that match your funnel:
- view_item_list โ fires on category pages and search results when product cards are displayed. Enables product list performance reporting.
- select_item โ fires when a user clicks a product card. Links list position to eventual purchase for attribution.
- view_item โ fires on the product detail page. Measures engagement and enables conversion funnel analysis from PDP to purchase.
- add_to_cart โ fires when a product is added. Enables cart abandonment analysis and remarketing audience creation.
- begin_checkout โ fires at checkout initiation. The critical funnel step for identifying checkout abandonment.
- purchase โ the most important event. Must include
transaction_id,value,currency, and theitemsarray. This event drives all revenue reporting and Google Ads conversion attribution.
Critical Implementation Rules That Developers Frequently Miss
Even experienced developers make consistent mistakes when implementing GA4 ecommerce events. The most impactful ones to avoid:
- Always clear the ecommerce object first. Before every
dataLayer.push()with an ecommerce event, push{ ecommerce: null }. Without this reset, GTM may merge the previous ecommerce object with the new one, causing contaminated data โ for example, items from a previousview_itemevent appearing in apurchaseevent. - Send
valueas a number, not a string. Thevaluefield must be a JavaScript number (49.99), not a string ("49.99"). Strings cause GA4 to record the transaction with a value of 0 in revenue reports. - Use ISO 4217 currency codes.
currencymust be a 3-letter ISO code (USD,EUR,GBP). Strings like"dollars","$", or"us dollar"are rejected. - Make
transaction_idunique per order. Duplicatetransaction_idvalues cause GA4 to deduplicate purchases โ the second identical transaction is silently ignored. Always use your order management system's order ID, never a session ID or timestamp.
Need Expert Tracking Setup?
Our team implements GA4, GTM, and conversion tracking for 200+ clients worldwide. Get a free audit.
Get a Free Consultation โ