Skip to content

Custom events

A custom event is an action your site reports by name, such as a completed signup or a booked demo. The script counts page views on its own; events are what you add, with one line of JavaScript where the action happens. This guide is for whoever writes your site’s code.

Send an event

With the tag from Install the script on the page, the script defines window.track. Call it once the action has succeeded, with the event’s name and, if you like, a few properties:

Your client code
// After the signup request succeeds
window.track?.("signup_completed", { plan: "team" });

// Page views, including client-side route changes, are sent automatically.

The ?. makes the call do nothing when the script isn’t there, for example when a content blocker stopped it, so your page never breaks because of it. track exists once the script has run: with the HTML tag (defer), once the page has been parsed; with the Next.js tag (afterInteractive), after the page has hydrated, so a component’s first effect on a page that loads fresh runs before it. A call before then is lost, not queued, so send events when the action happens, not as a page first renders.

Each call sends one event, as its own request. The request can finish after the page unloads, so an event sent as a link is followed or a form is submitted still goes. With Via your domain, events take the same path as page views.

Names and properties

WhatRules
Event name1 to 64 characters: the letters a–z and A–Z, digits, spaces, and _ . : -, not starting with a space. Names are case-sensitive: Signup and signup are two events.
PropertiesOptional. An object of up to 10 properties.
Property namesUp to 40 characters.
Property valuesText, cut at 200 characters; a number; or true or false.
revenue, currencyrevenue makes the event a payment, with currency when it isn’t your site’s; both count among its 10 properties. currency alone stays an ordinary property. See Send revenue with an event.

An event that breaks a rule is refused whole, and nothing of it is stored: a name with other characters, more than 10 properties, a property name over 40 characters, or a value that is null, an array, or an object. So is a request over 8 KB in all, the page’s address included: a long text value counts at its full length before it’s cut. Leave a property out rather than sending it as null.

Use one name for each action and put what varies in a property: signup_completed with { plan: "team" }, not signup_team. Goals, funnels, and the other reports find an event by its exact name.

Where events show

Open your site and choose Goals & events in the sidebar, under Behavior (or press G, then E). The Custom events table lists every event sent in the period with its Completions, Converted, Rate, a Revenue column where an amount was sent, and its trend. An event that is also a goal shows the goal’s name beside it. Select an event to open its page:

On its pageWhat it is
CompletionsEvery time the event was sent in the period, repeats included.
Converted visitorsDistinct visitors who sent it at least once.
Conversion rateConverted visitors ÷ every visitor who started a visit in the period, with the same segment, cohort, and filters.
BreakdownWho converts, by channel, source, device, country, and entry page. A row’s rate shows from 50 visitors; select a row to filter the page by it.
PropertiesThe values sent with the event, for the two properties it carries most often. Every property you send is kept, and the raw data download has them all where Individual visits is on.
Most recent completionsWhen, from where, from which source, on what device, and the values sent. Only on sites with Individual visits on.

Events also show in the Overview’s Goals & events panel, as steps of a visit in Sessions (with Individual visits on), and in reports: a step of a funnel or a journey, the start or return in Retention, how a cohort starts, and the goal of Attribution. To count an event as a conversion, make it a goal.

How events count

  • Usage. Each event counts toward your plan, as a page view does.
  • Bounces. A visit with a custom event isn’t a bounce: bounce rate counts visits with one page view and no events.
  • Visits. An event keeps its visit going. One sent after 30 minutes without activity starts a new visit, on the page it was sent from.
  • Retries. Each request carries a random ID, so a request sent twice counts once. Calling track twice sends two events.
  • Bots. Events from bots are left out of every number, as their page views are, and counted in the Bots panel. Send events from the browser: requests from servers, such as curl or Node’s fetch, are treated as bots.
  • Hostnames. An event sent from an address your site doesn’t count is turned away, as a page view is (Choose which hostnames count).

Check that it arrives

Do the action on your live site, then open Goals & events and pick Today in the period menu (or press D). Reload it if it was open. When the period leaves out today, an event or goal that has none in the period but some today is named at the top, with Show today. If nothing shows, find the script’s request in your browser’s network panel: to /api/event, or to your own path with Via your domain.

You seeWhat to do
No request at allThe script didn’t load or was blocked; try another browser, or Via your domain. A browser that excludes your own visits sends nothing: run localStorage.removeItem("_aoff") to undo it. Automated browsers, such as test runners, send nothing either.
400The name or a property breaks a rule above. The answer’s error says which.
402Your workspace isn’t recording: its trial or plan ended more than 14 days ago (Plans and usage).
403The page’s address isn’t one your site counts (“Host … is not allowed for this site”). Check Settings › General › Hostnames; for localhost, tick Also accept page views from localhost in Tracking.
413The request is over 8 KB: send fewer or shorter properties.
429Too many requests from your address in a short time. Wait and try again; the answer’s Retry-After says how many seconds.
202 {"ignored":"bot"}The request came from a bot or a server tool, so it’s left out.
The event shows, its goal doesn’tThe goal’s event name differs from the one your code sends. Names are case-sensitive.

Privacy

  • No personal data. Don’t send names, email addresses, user IDs, or order numbers in event names or properties. We keep them as you send them.
  • Consent. Events go through the same script as page views and set no cookies. Whether you need your visitors’ consent depends on the country; in Sweden and Germany, assume you do. Where your tag has data-remember, events carry the ID it keeps in the browser, which needs consent in the EU and UK (consent, by place).
  • Who sees properties. Share links, API keys, and AI assistants read an event’s totals, never its property values or single completions.
  • How long. Events are kept with the visits: while your workspace has a trial or a plan, and deleted 60 days after it ends (how long we keep it).