TapCub is live — analytics, insights and live chat, free on one platform

Free tool Data layer generator for GA4, GTM and TapCub

Choose one of Google’s 35 recommended events, fill in the parameters, and copy a ready dataLayer.push with the matching Google Tag Manager setup — or the gtag call, or the same event for the TapCub website script and SDKs. Required parameters, currency, item totals and GA4 naming limits are checked as you type.

  • dataLayer · gtag · GTM
  • Checks against Google’s rules
  • Runs locally
Data layer

Pick an event, get the code

Parameters are one per line as name=value; changing the event fills in the example values from Google’s reference. Put quotes around a value to keep it as text (an order number like "00123").

One per line, name=value. Lines starting with # are ignored.

One item per line: item_id=…; item_name=…; price=…; quantity=…

Checks

  • OKMatches Google’s reference for this event.
dataLayer.push
window.dataLayer = window.dataLayer || [];

dataLayer.push({ ecommerce: null }); // Clear the previous ecommerce object.
dataLayer.push({
  event: "purchase",
  ecommerce: {
    currency: "USD",
    value: 72.05,
    customer_type: "new",
    transaction_id: "T_12345",
    coupon: "SUMMER_SALE",
    shipping: 5.99,
    tax: 3.6,
    items: [
      {
        item_id: "SKU_12345",
        item_name: "Stan and Friends Tee",
        item_category: "Apparel",
        price: 10.01,
        quantity: 3
      },
      {
        item_id: "SKU_12346",
        item_name: "Google Grey Women's Tee",
        item_category: "Apparel",
        price: 21.01,
        quantity: 2
      }
    ]
  }
});

Put this where the action happens (after the order is confirmed, when the item is added…).

Google Tag Manager setup
1. No variables needed: the tag reads the ecommerce object directly.
2. Triggers › New › Custom Event
  Event name: purchase    This trigger fires on: All Custom Events
3. Tags › New › Google Analytics: GA4 Event
  Measurement ID: G-XXXXXXXXXX (the same ID as your Google tag)
  Event Name: {{Event}}  (or type purchase)
  More Settings › Ecommerce › Send Ecommerce data, Data Source: Data Layer
  Triggering: the "purchase" Custom Event trigger
4. Preview: open Tag Assistant, run the action, check the event in GA4 DebugView.

One trigger and one tag per event. Ecommerce events read the ecommerce object, so no variables are needed.

Parameters in Google’s reference

ParameterTypeRequiredExample in Google’s referenceYours
currencystringConditionalUSDset
valuenumberConditional72.05set
customer_typestringNonewset
transaction_idstringYesT_12345set
couponstringNoSUMMER_SALEset
shippingnumberNo5.99set
taxnumberNo3.6set
itemsarray of itemsYes—set
gtag.js (without GTM)
// Needs the Google tag (gtag.js) on the page already.

gtag('event', "purchase", {
  currency: "USD",
  value: 72.05,
  customer_type: "new",
  transaction_id: "T_12345",
  coupon: "SUMMER_SALE",
  shipping: 5.99,
  tax: 3.6,
  items: [
    {
      item_id: "SKU_12345",
      item_name: "Stan and Friends Tee",
      item_category: "Apparel",
      price: 10.01,
      quantity: 3
    },
    {
      item_id: "SKU_12346",
      item_name: "Google Grey Women's Tee",
      item_category: "Apparel",
      price: 21.01,
      quantity: 2
    }
  ]
});

Use this instead of the dataLayer push if the site loads gtag.js directly.

Runs entirely in your browser. Nothing you type here is uploaded or stored by TapCub.

Share these inputs: the values go after the # in the link, so they never reach a server.

Version v1.0Updated Update history

Read the result

Which block to use

They describe the same event. Pick the one that matches how tags are installed on your site.

dataLayer.push + GTM

If the site uses Google Tag Manager. The page only pushes data; GTM decides which tags fire. Ecommerce events go inside an ecommerce object, cleared first with { ecommerce: null } so values from the previous event do not leak in.

gtag.js

If the Google tag is pasted straight into the page without GTM. Same event name and parameters, sent immediately.

TapCub SDK call

The same event for TapCub. The website, mini-program and app SDKs keep flat values only, so items are left out; the server SDKs keep one level of objects, so order lines and payments belong there.

Checks

Errors break reporting (a missing transaction_id, value without currency). Checks are worth a look (value not equal to the item total). Notes explain what happens, such as custom parameters needing a custom dimension.

“Yes” under Required means Google lists the parameter as required. “Conditional” is Google’s Yes*: currency is required once value is set, and value is needed for revenue reporting. “See note” is Google’s No*: items are optional, but without them refunds have no item-level refund metrics and select_promotion is left out of the Promotions report.

How to use it

From event to working tag

Most of the work is choosing the event and making the values come from your page, not this example.

  1. 1

    Pick the event

    Use a recommended event when one fits — GA4 reports understand them. Otherwise choose “Custom event” and name it.

  2. 2

    Fill in the parameters

    Replace the example values with your own, or keep them while you test. Watch the checks.

  3. 3

    Copy the code

    Replace the literals with your variables (order number, total, cart lines) and run it where the action completes.

  4. 4

    Set up and test

    Follow the GTM steps, then check the event in Tag Assistant and GA4 DebugView — or in TapCub’s realtime view.

Rules

The rules the checks use

All GA4 rules are from Google’s own pages, checked on 2026-11-10: the recommended events reference, event naming rules and collection limits.

  • value should equal the sum of price × quantity over the items, without shipping and tax; currency is a 3-letter ISO 4217 code and is required whenever value is set.
  • Every item needs item_id or item_name; quantity defaults to 1.
  • Event and parameter names are at most 40 characters and values at most 100, counted after URL encoding — non-Latin text uses the limit up faster. At most 25 parameters per event.
  • For TapCub, event names registered in the catalog are lowercase snake_case up to 40 characters; the website script keeps 20 properties, mini-program and app SDKs 30.
Where the limits come from
LimitGA4TapCub
Event name40 characters, starts with a letter40 characters, lowercase snake_case
Parameters / properties per event25Web 20 · mini program / app 30 · server 50 stored
Text value100 characters200 (client SDKs) · 1,000 (server)
Arrays of objectsitems, up to 27 custom item parametersServer only (up to 100 elements)
Reserved prefixes_ firebase_ ga_ google_ gtag. (parameters)$ _ tc_
Worked example

One purchase, three ways

The default example is Google’s own purchase sample: two items, 10.01 × 3 + 21.01 × 2 = 72.05.

The same order in each block
BlockEvent nameOrder numberAmountItems
dataLayer / gtagpurchasetransaction_idvalue 72.05 + currencyitems array
TapCub websitepurchaseorder_idrevenue 72.05 + currencyleft out (flat values only)
TapCub server (Node.js)purchaseorder_id and insertIdrevenue 72.05 + currencyitems array kept

Renaming value → revenue and transaction_id → order_id is the “commerce report’s default names” option. Turn it off to keep GA4’s names; then set the mapping in TapCub’s business settings instead.

Common mistakes

Why data layer events go missing

The code is short; the mistakes are in timing and values.

Not clearing ecommerce

Without dataLayer.push({ ecommerce: null }) first, items from a previous event can merge into the next one, because GTM keeps the data layer as one merged state.

Purchase fired on page reload

A thank-you page that pushes purchase on every load counts refreshes as orders. Fire once per order, and send the order from the server as well if revenue matters.

Numbers sent as text

“72.05” in quotes, or “1,299.00” with a comma, is a string. GA4 cannot sum it as revenue.

Custom parameters that never show up

A parameter that is not in Google’s list is collected but only appears in reports once you register it as a custom dimension or metric.

FAQ

Data layer questions

Still have a question?

Chat with the team behind TapCub — we usually reply within a few hours on business days.

What is a data layer?

A JavaScript array, window.dataLayer, that the page pushes events and values into. Google Tag Manager reads it and decides which tags to fire, so the page does not need to know about each tool.

How do I push an event to the data layer?

Call dataLayer.push({ event: "sign_up", method: "Google" }). In GTM, a Custom Event trigger with the same event name fires the tag, and Data Layer Variables read the other keys. This tool writes both the push and the setup steps.

Why push { ecommerce: null } first?

GTM merges every push into one data layer state. Clearing the ecommerce object first stops items from the previous event ending up in the next one. It is the pattern in Google’s ecommerce guide.

What is the difference between dataLayer.push and gtag?

gtag sends the event straight to Google Analytics. dataLayer.push only records it in the page; GTM then sends it to GA4 and any other tag. gtag itself works by pushing into the same dataLayer array.

Which GA4 parameters are required?

It depends on the event: purchase needs transaction_id and items; search needs search_term. currency is required whenever value is set. The parameter table under the code shows the list for the event you pick.

Can I send the same event to GA4 and TapCub?

Yes. Keep the same event name. TapCub’s website script takes flat values, so send line items from the server; the commerce report reads revenue, currency and order_id by default, which the rename option fills in.

Does the TapCub code send personal data?

Only what you put in. The server examples have a USER_ID placeholder for your own ID; email and phone identifiers are hashed by the SDKs, but do not put them in event properties.

Is anything uploaded?

No. The code is generated in your browser; nothing you type is sent anywhere.

Changelog

Update history

New features, fixes and data refreshes for this tool, newest first.

  1. · v1.0

    LaunchedFirst release.

Data this tool relies on

  • GA4 recommended events — checked 2026-11-10, reviewed every 6 months (next review by 2027-05-10)

Missing something or found an error? Tell us — requests that come up often go into the next update. All tool updates

See your data clearly. Find your growth.

Every click, backed by data. Install one line of code and see your first numbers in a minute.

No credit card · Free plans for analytics and chat · Cookieless analytics