Skip to main content
Zenovay
Free5 minutesBeginner

Custom events: how do I send a custom event from JavaScript?

Use the global window.zenovay() function to send a named event with optional properties. Here's the API and a few common patterns.

custom-eventsjavascripttracker-api
Last updated:

Once the Zenovay tracker is loaded on your page, it exposes a global function window.zenovay() that accepts a custom event name and an optional properties object. Use it to track anything that isn't a pageview — clicks, form submissions, business events.

The simplest call

window.zenovay('cta_clicked');

That sends a single event with no properties. It will appear in Events → Custom Events in your dashboard within ~30 seconds.

With properties

window.zenovay('cta_clicked', {
  cta_label: 'Start free trial',
  page_section: 'hero',
  variant: 'B'
});

Property values can be strings, numbers, or booleans. Nested objects and arrays are not supported — flatten them at the call site.

Revenue events

For purchases, use the special revenue field:

window.zenovay('purchase', {
  revenue: 29.00,
  currency: 'USD',
  product_id: 'pro-annual',
  customer_id: 'cust_123'
});

The revenue and currency fields populate your revenue dashboard. customer_id is optional but enables identified-user analytics if you set it.

Identifying a user

When a visitor logs in, link the anonymous session to their account:

window.zenovay.identify('user_42', {
  email: 'jane@example.com',
  plan: 'pro'
});

After this call, all subsequent events are tagged with user_42 until the page reloads or you call window.zenovay.reset() (e.g. on logout).

Property naming conventions

Use snake_case (page_section, not pageSection). The dashboard groups properties alphabetically — consistent naming makes filters easier.

Reserved names that the tracker sets automatically and you should NOT override:

  • url, referrer, screen_size, browser, os, country, city

If you set them, they're silently dropped.

Plan limits

Custom events count toward your monthly event quota:

PlanMonthly events
Free10,000
Pro100,000
Scale1,000,000
EnterpriseCustom

Common pitfalls

  • Calling before the tracker loaded — wrap calls in a if (window.zenovay) check, or use the deferred queue: window.zenovayQueue = window.zenovayQueue || []; window.zenovayQueue.push(['cta_clicked']).
  • Sending PII as a property — emails, names, phone numbers should not be sent as custom event properties. Use identify() instead, where the data is hashed at rest.
  • Cookieless mode + identify() — when running in cookieless mode the identify call still works for the current page, but the link is reset on the next page load (no persistent storage).

Was this article helpful?