Skip to content
Workshop tools
All tools

dataLayer validator

Paste a dataLayer event, validate it against a schema, and catch personal data before it ships.

Runs in your browser. Nothing is uploaded.

Tool

Mode

One event object, an array of events, or a dataLayer.push({...}) call. JSON only: double-quoted keys and strings.

0 lines, 0 characters

No event detected yet. Choose a schema to override it.

Results

Paste a dataLayer event to see results.

Built-in schemas

This tool validates the GTM dataLayer shape: { event, ecommerce: { ... } } for ecommerce events, and top-level parameters for the others. Gtag-style top-level parameters are accepted and noted. A parameter is an error only where Google's reference says it is required; missing recommended parameters are warnings.

  • view_item

    Required: items; currency when value is set

    Google reference · checked against the docs on 2026-11-05

  • select_item

    Required: items

    Google reference · checked against the docs on 2026-11-05

  • add_to_cart

    Required: items; currency when value is set

    Google reference · checked against the docs on 2026-11-05

  • begin_checkout

    Required: items; currency when value is set

    Google reference · checked against the docs on 2026-11-05

  • purchase

    Required: transaction_id, items; currency when value is set

    Google reference · checked against the docs on 2026-11-05

  • sign_up

    Required: none

    Google reference · checked against the docs on 2026-11-05

  • login

    Required: none

    Google reference · checked against the docs on 2026-11-05

  • search

    Required: search_term

    Google reference · checked against the docs on 2026-11-05

  • generate_lead

    Required: none; currency when value is set

    Google reference · checked against the docs on 2026-11-05

Every item in an items array needs item_id or item_name. Items must not be empty. value must be a number. purchase needs transaction_id.

How the PII check works

These are heuristics on string values, not proof. Order numbers, SKUs and timestamps are deliberately not flagged as phone numbers.

  • Email: something@something.tld anywhere in a string value.
  • Phone: a whole value of 8 to 15 digits with spaces, brackets, hyphens or a leading +, that is not a date; or 7 to 15 digits under a key named phone, tel or mobile.
  • Payment card: 13 to 19 digits, with spaces or hyphens allowed, that pass the Luhn check.
  • Long digit run: 12 or more digits with no separators under a key that is not an id, sku, time, date, order or transaction key, and that is not a Unix timestamp.

Examples

Valid purchase
{
  "event": "purchase",
  "ecommerce": {
    "transaction_id": "T_12345",
    "currency": "USD",
    "value": 14.98,
    "shipping": 3.99,
    "tax": 1,
    "items": [
      {
        "item_id": "SKU_12345",
        "item_name": "Stan and Friends Tee",
        "price": 9.99,
        "quantity": 1
      }
    ]
  }
}
Invalid: transaction_id removed
{
  "event": "purchase",
  "ecommerce": {
    "currency": "USD",
    "value": 14.98,
    "shipping": 3.99,
    "tax": 1,
    "items": [
      {
        "item_id": "SKU_12345",
        "item_name": "Stan and Friends Tee",
        "price": 9.99,
        "quantity": 1
      }
    ]
  }
}
How to use this in CI

Treat each event as a contract. Download a schema from the tool, capture the events your page pushes in your own browser automation (for example by reading window.dataLayer), and validate them with Ajv in your build.

import Ajv from 'ajv';
import { readFileSync } from 'node:fs';

const ajv = new Ajv({ allErrors: true, strict: false });
const validate = ajv.compile(JSON.parse(readFileSync('purchase.schema.json', 'utf8')));
const event = JSON.parse(readFileSync('captured-event.json', 'utf8'));

if (!validate(event)) {
  console.error(validate.errors);
  process.exit(1);
}
What this can't check
  • It never reads a live page's dataLayer. It checks only what you paste.
  • The built-in schemas are not complete definitions. They cover the parameters Google's event reference marks as required or recommended, plus the documented types.
  • Whether a tag in Tag Manager actually fires, or whether GA4 accepts the event, is outside what this checks.
  • The PII check is a heuristic. It will miss personal data it cannot recognise and may flag harmless values.
  • The currency format check (three uppercase letters) is a hygiene check, not a rule stated in Google's reference.
  • Input must be JSON. JavaScript object literals with single quotes or unquoted keys are not accepted.

References

See more of my work