Free tool by MD Niamul

Free dataLayer Generator Build GA4 Ecommerce and Lead Event Code for Google Tag Manager

Correct dataLayer.push Code in Seconds, with the GTM Setup to Match

Works instantly in your browser
25 events, GA4 format
GTM, gtag, Meta and Shopify

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.

25Events ready to build
5Output formats
850+Projects delivered
600+Five-star reviews
MD Niamul, creator of the free datalayer generator
upworkTop Rated Plus
dataLayer + GTMFree Generator Tool
OfficialStape Partner

What the dataLayer Generator Builds

purchase
add_to_cart
begin_checkout
view_item
view_item_list
add_payment_info
refund
generate_lead
sign_up
search
items Array
event_id
user_data
Clear Ecommerce
gtag.js
Meta Pixel Event
Shopify Custom Pixel
GTM Variables
FREE DATALAYER GENERATOR

Generate Your dataLayer Code

Choose an event and edit the values. The code updates as you type.

dataLayer GeneratorGA4 ecommerce · Lead events · gtag · Meta Pixel · Shopify pixel · GTM setup
Free · No login

1. Choose the event

Ecommerce

Leads and sign-ups

Other

2. Fill in example values

3. Options

Your code

Google’s GA4 ecommerce formatCopy or download as a .js fileIncludes the GTM setup steps
WHAT IT BUILDS

What Does the dataLayer Generator Give You?

One event, written five ways, plus the Google Tag Manager setup.

dataLayer.push Code

The event in Google’s GA4 ecommerce format, with the items array built for you.

14 Ecommerce Events

From view_item_list and add_to_cart to purchase and refund.

Lead and Sign-Up Events

generate_lead, sign_up, login, search, contact, booking, trial and subscription.

gtag.js Version

For sites that use the Google tag directly, without Tag Manager.

Meta Pixel Version

The matching fbq event with content_ids, contents and an optional event ID.

Shopify Custom Pixel

A Customer Events starting point that maps Shopify’s checkout data to GA4 fields.

GTM Setup Steps

The trigger, each Data Layer Variable and the GA4 Event tag settings.

event_id and user_data

Optional fields for Conversions API deduplication and enhanced conversions.

How Does the dataLayer Generator Work?

Three steps. Nothing you type is sent anywhere.

01

Pick an event

Choose from GA4’s ecommerce and lead events, or name your own.

02

Enter example values

Order ID, value, currency and items. They show your developer exactly what belongs where.

03

Copy the code

Take the dataLayer code, or switch tabs for gtag, Meta Pixel, Shopify or the GTM setup.

What Is the dataLayer?

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.

Why clear the ecommerce object first?

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.

What are event_id and user_data for?

  • event_id is a unique code for one event. Send the same ID from the Meta Pixel and from the Conversions API so Meta counts the event once.
  • user_data holds the customer’s email and phone. Google’s enhanced conversions and the ad platforms’ conversion APIs use it, hashed, to match more conversions. Only include it where you have the customer’s consent.

Where does the code go?

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.

What this tool does not do

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.

GA4 Ecommerce Events and When to Send Them

The standard funnel, in order.

EventSend it whenKey fields
view_item_listA category or search results page is shownitems, item_list_name
select_itemA product is clicked in a listitems
view_itemA product page is viewedcurrency, value, items
add_to_cartA product is added to the cartcurrency, value, items
view_cartThe cart is viewedcurrency, value, items
begin_checkoutCheckout startscurrency, value, items
add_shipping_infoShipping details are submittedshipping_tier, items
add_payment_infoPayment details are submittedpayment_type, items
purchaseThe order is confirmedtransaction_id, value, currency, items
refundAn order is refundedtransaction_id

Who Is This Generator For?

Developers

Get the exact structure without reading the documentation again.

Analysts and agencies

Hand a developer a precise specification.

Store owners

Understand what your tracking needs before you hire someone.

GTM beginners

See how the dataLayer, variables, trigger and tag fit together.

MORE FREE TOOLS

More Free Marketing Tools by MD Niamul

33 free tools for tracking, analytics, advertising and SEO. No login needed.

Free Product Schema & Add to Cart Script Generator

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 →

Free GA4 Event Checker

Validate GA4 event names and parameters against Google’s rules before you publish.

Open the GA4 event checker →

Free UTM Builder

Create clean UTM links with platform presets, GA4 channel preview and bulk export.

Open the UTM builder →

Free SHA-256 Hashing Code Generator

Turn your email, phone and address variables into correctly formatted, hashed values for each ad platform.

Open the hashing generator →

Trusted by 600+ Brands & Agencies

MYLENE
HOVER BOARDS
GT SOLI
CAMBRIDGE
BIENEN CORB 24
ZULU SHACK CREATIVE
ADPSY LLC
HIGH PERFORMANCE MEDIA
ADS PERFORMANCE
LEGESI
TESTIMONIAL

Analytics & Conversion Tracking Client Testimonials

Hear from our clients. Loved by 600+ businesses worldwide.

Madison Jonas, client of MD Niamul
Madison JonasGoogle Ads clientLinkedIn recommendation
★★★★★

“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.”

Mehboob Khan, client of MD Niamul
Mehboob KhanGoogle Analytics projectsLinkedIn recommendation
★★★★★

“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.”

Jacco Bouw, client of MD Niamul
Jacco BouwShopify, GA4 & Google Ads trackingLinkedIn recommendation
★★★★★

“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.”

Ryan S Kemp, client of MD Niamul
Ryan S KempCMO, Co-Founder, Zulu Shack CreativeLinkedIn recommendation
★★★★★

“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.”

Casper Klein, client of MD Niamul
Casper KleinMeta Pixel & server-side trackingLinkedIn recommendation
★★★★★

“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.”

600+

Five-star reviews from businesses and agencies in the USA, Canada, UK and Australia.

Read All Reviews

Video Testimonials: Hear It From Our Clients

FAQ

Frequently Asked Questions About the Free dataLayer Generator

Is the dataLayer generator free?

Yes. It runs in your browser with no login, and nothing you type is sent anywhere.

What is a dataLayer push?

A line of JavaScript, dataLayer.push({...}), that tells Google Tag Manager something happened on the page and gives it the details.

Is the code in Google’s GA4 format?

Yes. Ecommerce events use the event name, the ecommerce object and the items array as Google documents them for GA4.

Can I paste the code straight into my site?

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.

Why does it push ecommerce: null first?

To clear values left by an earlier ecommerce event, so they do not leak into this one. Google recommends it.

What do I create in Google Tag Manager?

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.

Does it work for Shopify?

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.

What is the event ID for?

Deduplication. When the browser pixel and the Conversions API both send an event with the same ID, Meta counts it once.

How do I test the code?

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.

Need the dataLayer Built and Tested for You?

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.