Custom Events
Track clicks, form submissions, video views, and other interactions on your site.
Basic usage
Use the va() function to send events:
// Syntax
va('event', 'Event Name', { optional: 'properties' });
// Examples
va('event', 'Button Click');
va('event', 'Signup', { plan: 'pro' });
va('event', 'Download', { file: 'whitepaper.pdf', size: '2.4MB' });Common examples
Button click
<button onclick="va('event', 'CTA Click', { button: 'hero' })">
Get started
</button>Form submission
<form onsubmit="va('event', 'Form Submit', { form: 'contact' })">
<input type="email" name="email" required />
<button type="submit">Submit</button>
</form>Outbound link
<a href="https://partner.com"
onclick="va('event', 'Outbound Link', { url: 'partner.com' })"
target="_blank">
Visit our partner
</a>File download
<a href="/files/report.pdf"
onclick="va('event', 'Download', { file: 'report.pdf' })"
download>
Download report (PDF)
</a>Event properties
You can send any metadata as properties. These are saved as JSON and can be used to filter and analyze events later.
va('event', 'Purchase', {
productId: '12345',
productName: 'Premium Plan',
price: 299,
currency: 'USD'
});Check if script is loaded
If you want to make sure the script has loaded before sending events:
// Safe method
if (typeof va !== 'undefined') {
va('event', 'My Event');
}
// Or with optional chaining
window.va?.('event', 'My Event');Tip
Keep event names short and consistent. Use either English or Swedish consistently, and avoid special characters.
Events vs Goals vs Properties
It's important to understand the difference between these three concepts:
| Concept | What is it? | Where do I see it? |
|---|---|---|
| Events | Raw data saved when va('event', ...) is called. ALWAYS saved automatically. | Events log |
| Properties | Metadata sent with events (e.g., product_id, category_slug). Only whitelisted properties are saved. | Properties tab (site detail view) |
| Goals | A RULE that matches events or pageviews. You must create the goal separately in the dashboard. | Goals section + site detail view |
Important to understand
You do NOT need to create a goal for events to be saved. Events are always saved when va() is called.
Goals give you an extra "counter" with trend arrow and conversion rate - useful if you want to track specific conversions over time.
Example: Affiliate click
Here's how it works in practice:
- 1. Send event:
va('event', 'affiliate_click', {'product_id': '123'})
→ Event + properties are saved automatically - 2. View in Properties tab: Select product_id in dropdown to see which products are clicked most
- 3. (Optional) Create goal: If you want to see affiliate click count with trend → create goal with event name "affiliate_click"
View events in the dashboard
Events are shown in the Savri dashboard. You can:
- Properties tab - See breakdown of event properties (product_id, category_slug, etc.)
- Goals section - Create goals that match specific event names
Prompt your AI
Copy the prompt below and paste it into your favorite AI (ChatGPT, Claude, etc.) to get help setting up event tracking on your site.