Free tool
GA4 Ecommerce DataLayer Generator
Pick the event, fill in the fields and the items: the tool writes the ecommerce dataLayer.push that GA4 expects, in the format of Google’s examples, and checks that no required parameter is missing.
Every Google ecommerce example starts with dataLayer.push({ ecommerce: null }) to clear the previous object. If a required parameter is missing, GA4 still receives the event, but treats it as a custom event rather than an ecommerce event.
Fields marked * are required, and currency becomes required as soon as value is set. Without them, GA4 treats the event as a custom event.
Items
Each item needs at least item_id or item_name. Without quantity, the quantity is 1. Up to 200 items.
Code to add to your page
In Google Tag Manager, open your GA4 Event tag: under More Settings > Ecommerce, select Send Ecommerce data, and set Data Source to Data Layer.
Sources read on November 6, 2026: Google, Measure ecommerce and Google, Events reference.
Your dataLayer Is Ready. Will Your GA4 Revenue Be Right?
Code that is right on paper can still lose sales along the way: I check your ecommerce tracking from product page to purchase, and reconcile it with your real orders.
20 minutes · No commitment · 100% confidential
How the tool builds your dataLayer
value = Σ (price × quantity) of the items, without shipping or tax
The code starts with dataLayer.push({ ecommerce: null }), the line Google puts before each of its examples with the comment “Clear the previous ecommerce object”: it clears the ecommerce object of the previous event. The tool keeps it exactly as is.
Required parameters change from one event to the next: purchase needs transaction_id, value, currency and items, while select_item only needs items. Fields marked * follow Google’s events reference, and the tool warns you as soon as a required one is missing.
value is the sum of price × quantity for the items. With the two items in the example: 2 × 25 + 1 × 19.9 = 69.9. Shipping and tax go in shipping and tax, never in value.
What the generated code is for
- A brief for your developer: generate the code for each step of the funnel, from view_item to purchase, with example values, and send it as is.
- A purchase counted as ecommerce: check that no required parameter is missing before going live, so the purchase shows up in GA4’s ecommerce reports.
- A tag that reads the code: once the code is in place, your GA4 Event tag in Google Tag Manager reads the dataLayer and sends the ecommerce data.
Frequently asked questions
Why start with ecommerce: null?
Because Google puts this line before each of its examples, with the comment “Clear the previous ecommerce object”: it clears the ecommerce object of the previous event before the new one is sent.
Which parameters are required for purchase?
transaction_id, value, currency and items. tax, shipping, coupon and customer_type are optional, but Google advises setting every parameter you have data for.
How many items can the items array hold?
Up to 200. Each item needs at least item_id or item_name, and Google recommends providing both.
Period or comma for decimals?
You can type either: the tool always writes a period in the code, because value, price, tax and shipping are JavaScript numbers there, 69.9 and not 69,9.


