DataLayer Builder + Validator
Build correct dataLayer.push() code for any GA4 event, or paste existing code to validate it.
Build mode: Select an event type, fill in the fields, and get ready-to-use code with live validation.
Validate mode: Paste existing dataLayer.push() code and get instant feedback on errors, warnings, and suggestions.
Start from Example
Event Type
User completes a purchase transaction
Options
Event Parameters
Your order ID from your backend/CMS (e.g., Shopify order number). Must be unique per transaction — GA4 uses this to deduplicate revenue.
3-letter currency code matching your store (e.g., USD, EUR, SEK). Must match the currency of the value field.
Total order revenue including tax and shipping. Must be a number — this is what GA4 reports as revenue.
Tax amount for this order. Must be a number.
Shipping cost for this order. Must be a number.
Order-level coupon code applied to this purchase.
Store or partner that fulfilled this order (e.g., 'Google Store', 'Partner Marketplace').
Items
Item 1
Your product SKU or ID from your catalog. Use the same ID across all events (view_item → add_to_cart → purchase) for funnel analysis.
Product name as shown to the user. GA4 uses this for reporting if item_id isn't set.
Unit price of this item. Must be a number — '29.99' (string) won't work, use 29.99 (number).
Number of this item. Defaults to 1 if omitted, but always include it explicitly.
Brand or manufacturer. Useful for brand performance reports in GA4.
Primary product category (e.g., 'Apparel'). Use category2-5 for sub-categories — don't put the full path here.
Second-level category (e.g., 'T-Shirts'). Build your hierarchy: Apparel > T-Shirts > Short Sleeve.
Third-level category. Don't skip levels — if you use category3, set category2 too.
Fourth-level category. Most implementations only need 2-3 levels.
Fifth-level category. GA4 supports up to 5 levels.
Product variant like color or size. Use a consistent format (e.g., 'Blue / Large').
ID of the list this item appeared in (e.g., 'search_results', 'related_products').
Display name of the list (e.g., 'Related Products', 'Search Results').
Position of the item in the list (0-based). Useful for tracking which position gets the most clicks.
Item-level coupon code, if different from the order-level coupon.
Discount amount applied to this item (as a positive number, e.g., 5.00).
Store or partner that fulfilled this item (e.g., 'Google Store', 'Amazon Marketplace').
Field Status
⚠️ Missing required fields: Transaction ID, Currency, Value
⚠️ Add at least one item with an item_id or item_name.
Generated dataLayer.push()
// Clear previous ecommerce data
dataLayer.push({ ecommerce: null });
dataLayer.push({
event: 'purchase',
ecommerce: {
items: [
{
quantity: 1
}
]
}
});