100% Free - No Account Required

Free DataLayer Generator

Generate properly formatted dataLayer.push() code for Google Tag Manager. Build e-commerce tracking, page views, user data, and custom events with our free dataLayer builder.

Transaction Data

List Data

Products (Items Array)

Page Information

User Properties

Push user data to the dataLayer for enhanced tracking and personalization.

Privacy-Safe User Data

For enhanced conversions. Hash before sending to the dataLayer in production.

Form Details

Use snake_case for GA4 compatibility (e.g., video_play, button_click)

Custom Parameters

Generated DataLayer Code

GTM Setup Tip

Want Automatic DataLayer Setup?

PixelFly automatically pushes properly formatted e-commerce events to your dataLayer. No coding required.

Start Free Trial

How the DataLayer Works

The dataLayer is the foundation of Google Tag Manager. Here's how to use it effectively.

1

Initialize DataLayer

Add this before your GTM container snippet:

window.dataLayer = window.dataLayer || [];
2

Push Events

Use dataLayer.push() to send data:

dataLayer.push({
  event: 'purchase',
  ecommerce: { ... }
});
3

Configure GTM

Set up triggers and tags in GTM:

  • - Create Custom Event triggers
  • - Use Data Layer Variables
  • - Connect to GA4 tags

GA4 E-commerce Events Reference

Complete list of GA4 e-commerce events and when to use them in your customer journey

Event When to Fire Required Parameters
view_item_list Category page, search results items[], item_list_id, item_list_name
select_item Product click from list items[], item_list_id, item_list_name
view_item Product detail page items[], currency, value
add_to_cart Add to cart button click items[], currency, value
view_cart Cart page view items[], currency, value
begin_checkout Checkout initiation items[], currency, value
add_shipping_info Shipping method selected items[], currency, value, shipping_tier
add_payment_info Payment info entered items[], currency, value, payment_type
purchase Order confirmation items[], transaction_id, currency, value
refund Order refund processed transaction_id, currency, value

DataLayer FAQ

Common questions about dataLayer implementation

A dataLayer is a JavaScript array that stores and passes information from your website to Google Tag Manager. It acts as a bridge between your site and GTM, allowing you to send page data, user information, e-commerce events, and custom variables to your tags. Think of it as a structured way to communicate data from your website to your analytics tools.
The dataLayer initialization and any data you want available on page load should be placed BEFORE the GTM container snippet in your HTML head. This ensures the data is available when GTM loads. Dynamic events (like add to cart) can be pushed after GTM loads, typically in response to user interactions.
Yes! It's best practice to clear the ecommerce object before pushing new e-commerce data. This prevents data from previous events from persisting and potentially causing incorrect tracking. Use dataLayer.push({ ecommerce: null }) before each e-commerce event push. Our generator includes this automatically.
GA4 uses a different data structure than Universal Analytics. GA4 uses an "items" array with standardized parameter names (item_id, item_name, etc.), while UA used "products" with different names (id, name). GA4 events use snake_case naming (add_to_cart) versus UA's camelCase. Our generator creates GA4-compatible dataLayer code by default.
You should push each event separately with its own dataLayer.push() call. This ensures each event triggers its corresponding GTM tags correctly. Combining multiple events in a single push can lead to missed triggers and incorrect data. The dataLayer persists throughout the page session, so sequential pushes are perfectly fine.

Skip the Manual DataLayer Setup

PixelFly automatically handles dataLayer implementation for your e-commerce store. Works with Shopify, WooCommerce, and custom sites.

No credit card required. 14-day free trial.

We use cookies to enhance your experience, analyze site traffic, and for marketing purposes. By continuing to use our site, you consent to our use of cookies. Learn more