No cookies · No consent banner · Data stored in EuropeNo cookies · GDPR · EU data

English
Conversions

How to track custom events with JavaScript

For actions that happen inside your code: a payment confirmed, a form step completed, a video watched to the end…

Documentation menu

Create the goal

New custom goal with name, key and value
  1. Settings → Goals → New goal → “Custom”.
  2. Give it a name and a key: letters, numbers and _ . : - (up to 64 characters), for example purchase or signup_step_2.
  3. Optional: a value in euros for each conversion.
  4. Save: the panel shows you the exact code with your key.

Call it from your code

Call _ovt() with the key at the moment the action happens. The tracking code must be installed on that page.

_ovt('purchase');

For example, when an asynchronous form is sent successfully:

form.addEventListener('submit', async (e) => {
  e.preventDefault();
  const res = await fetch('/api/contact', { method: 'POST', body: new FormData(form) });
  if (res.ok) _ovt('contact_sent');
});

Each call counts one conversion. Call it only when the action really happens (after the server confirms it), not on the click.

Online stores

The WooCommerce and PrestaShop integrations already send events for completed orders (with their value), checkout, cart, coupons and searches. See the guides in Integrations.

Can’t find what you’re looking for? Write to us and we’ll help you. Contact us