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.
Runs locally in your browser. Drafts stay on this device.
How practice works
- Read the task and correct the starter solution.
- Run it, then interact with the form, links or cart.
- 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.
- 01Not started
Send a form event
Correct a dataLayer.push and check its fields and types.
JavaScriptFunctions and objects - 02Not started
Configure a lead tag
Connect variables, a Custom Event trigger and a GA4 Event output.
Tag configurationEvent parameters - 03Not started
Calculate cart value
Write a Custom JavaScript variable using {{DLV - items}}.
Custom JavaScriptArrays and number conversion - 04Not started
Track outbound links
Write a Custom HTML listener that handles nested click targets.
Custom HTMLDOM events and URLs - 05Not started
Wait for a successful response
Handle an async response and prevent duplicate leads.
JavaScriptasync / await and Set - 06Not started
Build a purchase event
Account for discounts, shipping, tax and repeated payment responses.
JavaScriptObjects, arrays and deduplication