Skip to content
HomeTraining

Write the code. Check the event.

Six exercises for analytics implementation: forms, variables, triggers and purchases. Edit a solution and test it here. No GTM account needed.

Start with a form event

Runs locally in your browser. Drafts stay on this device.

How practice works
  1. Read the task and correct the starter solution.
  2. Run it, then interact with the form, links or cart.
  3. Check your solution against several inputs. Use a hint if you get stuck.

The lab supports dataLayer.push, Data Layer / Constant / Event / Custom JavaScript variables, Custom Event conditions and a local GA4 Event output. Custom HTML supports one inline script and the small DOM described in that exercise. No container, Preview connection, consent engine, templates, external scripts or GA4 delivery are included.

Choose an exercise

Follow the sequence or open the task you need.

  1. 01

    Send a form event

    Correct a dataLayer.push and check its fields and types.

    JavaScriptFunctions and objects
    Not started
  2. 02

    Configure a lead tag

    Connect variables, a Custom Event trigger and a GA4 Event output.

    Tag configurationEvent parameters
    Not started
  3. 03

    Calculate cart value

    Write a Custom JavaScript variable using {{DLV - items}}.

    Custom JavaScriptArrays and number conversion
    Not started
  4. 04

    Track outbound links

    Write a Custom HTML listener that handles nested click targets.

    Custom HTMLDOM events and URLs
    Not started
  5. 05

    Wait for a successful response

    Handle an async response and prevent duplicate leads.

    JavaScriptasync / await and Set
    Not started
  6. 06

    Build a purchase event

    Account for discounts, shipping, tax and repeated payment responses.

    JavaScriptObjects, arrays and deduplication
    Not started

Need to implement this on your site?