get_event_tracking_snippet
Retrieve a JavaScript snippet to fire custom events like signups or clicks from your site code. Add optional properties for later breakdown analysis.
Instructions
Return the JavaScript snippet for firing a custom event from the user's site code (e.g. window.gizmo("signup", {plan:"pro"})). Call this when the user says 'track signups', 'fire an event when someone clicks X', 'add custom event for Y', 'how do I track Z' — anything that means instrumenting a custom event in their codebase. The tracker script must already be installed (create_site or get_install_snippet handles that). After this call returns, EDIT the user's code to insert the snippet at the right code path — a click handler, a form-submit success branch, a router-change effect, etc. — based on what they're tracking. Don't just print the snippet; place it. Pass properties for any dimensions you want to break down later (plan, sku, variant, etc.); the dashboard can then roll up event counts by property via breakdown_by_property. Event name and property keys must be 1–64 chars, letters/digits/underscore (event name also allows dot and dash).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| event_name | Yes | Name of the custom event to fire (1–64 chars, letters/digits/dot/dash/underscore). Examples: 'signup', 'cta_click', 'purchase'. | |
| properties | No | Optional key-value props attached to the event. Strings, numbers, or booleans. Keys must be [A-Za-z0-9_]{1,64}. Use to enable breakdown_by_property later (e.g. {plan:'pro'} → group signups by plan). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| language | Yes | ||
| instructions | Yes | ||
| code | Yes | JS call to fire the event: window.gizmo(...) | |
| html_code | Yes | HTML variant for use inline in onclick='...' on a static page. |