Correct dataLayer.push Code in Seconds, with the GTM Setup to Match
Pick an event, fill in example values and this free dataLayer generator writes the dataLayer.push code in Google’s GA4 ecommerce format. It also gives you the matching gtag.js call, the equivalent Meta Pixel event, a Shopify custom pixel starting point, and the exact trigger, variables and tag to create in Google Tag Manager.
Choose an event and edit the values. The code updates as you type.
Ecommerce
Leads and sign-ups
Other
One event, written five ways, plus the Google Tag Manager setup.
The event in Google’s GA4 ecommerce format, with the items array built for you.
From view_item_list and add_to_cart to purchase and refund.
generate_lead, sign_up, login, search, contact, booking, trial and subscription.
For sites that use the Google tag directly, without Tag Manager.
The matching fbq event with content_ids, contents and an optional event ID.
A Customer Events starting point that maps Shopify’s checkout data to GA4 fields.
The trigger, each Data Layer Variable and the GA4 Event tag settings.
Optional fields for Conversions API deduplication and enhanced conversions.
Three steps. Nothing you type is sent anywhere.
Choose from GA4’s ecommerce and lead events, or name your own.
Order ID, value, currency and items. They show your developer exactly what belongs where.
Take the dataLayer code, or switch tabs for gtag, Meta Pixel, Shopify or the GTM setup.
The dataLayer is a list on your web page where your website writes down what just happened: a product was viewed, something was added to the cart, an order was placed. Google Tag Manager reads that list and passes the details to Google Analytics, Google Ads, Meta and other tools.
A dataLayer.push() adds one entry. For GA4 ecommerce, Google defines the exact structure: an event name and an ecommerce object with fields such as value, currency and an items array. Get the structure right and GA4 fills its ecommerce reports automatically.
The dataLayer remembers earlier values. If an add_to_cart push included a coupon and the next purchase push does not, the old coupon can leak into the purchase. Google recommends pushing { ecommerce: null } before each ecommerce event. The generator adds it for you.
Your developer, theme or plugin must run the code at the moment the action is confirmed, with real values in place of the examples: on the order confirmation page for purchase, after a successful form submission for generate_lead. On Shopify, checkout events have to come from a custom pixel under Customer Events, because theme code does not run on checkout pages.
It writes correct code for the values you enter. It cannot install the code or connect it to your store’s real order data. The Shopify pixel is a starting point that follows Shopify’s Web Pixels API and must be tested with a real order. Always check the result in GTM preview mode and GA4 DebugView.
The standard funnel, in order.
| Event | Send it when | Key fields |
|---|---|---|
| view_item_list | A category or search results page is shown | items, item_list_name |
| select_item | A product is clicked in a list | items |
| view_item | A product page is viewed | currency, value, items |
| add_to_cart | A product is added to the cart | currency, value, items |
| view_cart | The cart is viewed | currency, value, items |
| begin_checkout | Checkout starts | currency, value, items |
| add_shipping_info | Shipping details are submitted | shipping_tier, items |
| add_payment_info | Payment details are submitted | payment_type, items |
| purchase | The order is confirmed | transaction_id, value, currency, items |
| refund | An order is refunded | transaction_id |
Get the exact structure without reading the documentation again.
Hand a developer a precise specification.
Understand what your tracking needs before you hire someone.
See how the dataLayer, variables, trigger and tag fit together.
33 free tools for tracking, analytics, advertising and SEO. No login needed.
Enter a product page to get Product schema and view_item and add_to_cart JavaScript built for that page.
Open the product script generator →Validate GA4 event names and parameters against Google’s rules before you publish.
Open the GA4 event checker →Create clean UTM links with platform presets, GA4 channel preview and bulk export.
Open the UTM builder →Turn your email, phone and address variables into correctly formatted, hashed values for each ad platform.
Open the hashing generator →Hear from our clients. Loved by 600+ businesses worldwide.
“I had an excellent experience working with MD on my Google Ads account. Everything was set up perfectly and worked smoothly without any issues or troubleshooting needed. His expertise and attention to detail made the whole process effortless.”
“I worked with Niamul on multiple Google Analytics projects and was impressed by his expertise and precision. He has a strong grasp of tracking, reporting, and optimization, always ensuring accurate insights. He is proactive, reliable, and easy to collaborate with.”
“MD Niamul is extremely skilled. He fixed my Shopify, Google Analytics, and Google Ads conversion tracking perfectly. Everything works exactly as it should now, and he even added an extra data layer, which was very helpful. Outstanding service, fast delivery, and highly recommended.”
“Reliable, knowledgeable, and truly trustworthy. I’ve been working with Niamul for over a year, and he consistently delivers exceptional results across all analytics tasks. His expertise, communication, and commitment make him my go-to specialist for tracking, measurement, and data accuracy.”
“MD N delivered flawless Meta Pixel, CAPI, and server-side tracking. He understood our goals quickly, explained everything clearly, and ensured full transparency. Communication was smooth, updates were consistent, and the results improved our data accuracy and ad performance.”
Five-star reviews from businesses and agencies in the USA, Canada, UK and Australia.
Read All ReviewsYes. It runs in your browser with no login, and nothing you type is sent anywhere.
A line of JavaScript, dataLayer.push({...}), that tells Google Tag Manager something happened on the page and gives it the details.
Yes. Ecommerce events use the event name, the ecommerce object and the items array as Google documents them for GA4.
The structure is ready, but the values are examples. Your developer or platform must replace them with real values, such as the real order ID and total, at the moment the event happens.
To clear values left by an earlier ecommerce event, so they do not leak into this one. Google recommends it.
A Custom Event trigger with the event name, Data Layer Variables for the fields you need, and a GA4 Event tag. The GTM setup tab lists each one.
For storefront events, add the dataLayer code to your theme. For checkout and purchase events, use a custom pixel under Customer Events. The Shopify tab gives a starting point that must be tested with a real order.
Deduplication. When the browser pixel and the Conversions API both send an event with the same ID, Meta counts it once.
Open GTM preview mode, perform the action and check the event and its values in the Data Layer tab. Then confirm it in GA4 DebugView.
I am MD Niamul, a conversion tracking and web analytics specialist and an official Stape partner. I build data layers for Shopify, WooCommerce and custom sites, connect them through GTM and server-side tracking, and test every event.