Generate event tracking code instantly to measure clicks, downloads, form submissions, and other valuable user interactions on your website.
Start Building Your EventClick a template to pre-fill the builder with common event tracking setups.
Once you've generated your snippet, you need to add it to your website's HTML to trigger the event. The most common way is to add an `onclick` attribute to the element you want to track.
Copy the generated snippet and place it inside the `onclick` attribute of your button or link element:
For more advanced implementations, it's highly recommended to use Google Tag Manager (GTM). In GTM, you can create a "GA4 Event" tag and use triggers to fire it when a specific action occurs, keeping your website's HTML clean.
Event tracking allows you to measure specific user interactions on your site that aren't standard page loads, like button clicks, form submissions, or video plays. It provides deeper insight into user engagement.
Universal Analytics (UA) used a rigid structure: Category, Action, Label, and Value. Google Analytics 4 (GA4) uses a flexible model with an `event_name` and a flat list of custom parameters (key-value pairs). The GA4 model is more powerful and is the current standard.
Consistency is key. For GA4, use lowercase letters and underscores for event names (e.g., `button_click`, `form_submission`). For parameters, be descriptive (e.g., `link_text`, `file_name`). This keeps your data clean and easy to analyze in reports.