Event Code Generator
Pick the event, fill the ecommerce fields, and get the exact dataLayer.push() block — including the ecommerce clear that stops one purchase from overwriting the last.
Pick an event to generate the code.
How this tool works
Runs where you are
The page is static. Your input is processed by a script in your browser, and nothing is sent to BonicBD or stored on a server.
Shows its inputs
Every value the tool outputs is one you typed, or one BonicBD documents. If a default is applied, the tool names it.
No account needed
There is no sign-up, no email capture, and no rate limit tied to a plan. Open it, use it, close the tab.
What a dataLayer push actually is
A dataLayer push is an array append. It does not send anything to Google — it records an event object that a tag manager container can read and act on. Nothing happens until a trigger matches that object and a tag fires.
That is why a correctly formatted push can still produce zero events: the push was fine, the trigger was not. Debugging in the page console is the wrong end of the problem; debug the trigger in the container preview.
The ecommerce clear people leave out
GA4 ecommerce events accumulate into a single ecommerce object. Without a clear before each push, the items from the last event ride along with the next one, and a purchase arrives carrying the five products someone viewed an hour ago.
Every generated block here includes the clear first, because omitting it produces data that looks plausible and is wrong.
What belongs in the items array
item_id and item_name identify the product. price is the unit price, not the line total — quantity is separate, and the platform multiplies. Sending a line total as price doubles your revenue when quantity is above one.
Keep the array to the fields you will actually report on. An items array with fourteen speculative fields is harder to validate and no more useful.
Fields the generator will emit
| Field | Value to supply | What goes wrong if it is wrong |
|---|---|---|
| currency | BDT for Bangladesh stores | Revenue is read in the wrong currency and every ROAS figure is off |
| value | Order total as a number, no separators | A string is accepted by the push and dropped downstream |
| item_id | Your SKU, stable across the catalogue | Product-level reporting fragments into near-duplicates |
| price | Unit price, not the line total | Quantity above one inflates revenue |
| quantity | Integer count | A decimal is rejected by most destinations |
Questions about this tool
In a custom HTML tag in your container, triggered on the event that produced the values — or in your theme if the event happens outside the container.
Without it, the ecommerce object carries items from the previous event into the next one, so a purchase can arrive with products the visitor never bought.
A number. A quoted value passes the push and fails validation downstream, which is the least useful kind of bug.
The push is browser-side. For a server container you forward the event from a client tag, or send it directly from your own code.
Reading the result is step one
If the check turned up something you want to fix, the setup guide is the path from DNS to a verified event — or start a trial and watch a real event land on your own subdomain.