Tracking

Events

Send your own events, like sign_up or purchase, with a scope, a value and parameters. Naming, limits and what numbers does with them.

2 min read

An event is a name and a scope:

  • The name says what happened. Use snake_case, and the GA4 recommended names where they fit: sign_up, add_to_cart, purchase. The SDK warns once about any other.
  • The scope says where or what it was about: homepage_hero_signup, product_page. It is the stable second half of the event's identity. Without one, the SDK uses the page's path.

From the page

With the script, the client is on window.numbers:

numbers.track('sign_up', 'footer_form')

With the SDK:

numbers.track('add_to_cart', 'product_page', {
	value: 59.95,
	currency: 'EUR',
	params: { ecommerce: { items: [{ item_id: 'sku_1' }] } },
})

// At most once per key, e.g. one view_item per product.
numbers.track('view_item', 'list', { dedupeKey: 'sku_1' })
  • value and currency are summed into revenue per variant in Improve's test results.
  • params is any JSON object, stored with the event.

Every event also carries the page's path and UTM tags, like a page view.

The SDK's autoTrack() can count three more without your own code: outbound: true sends outbound_click for links to another site, downloads: true sends file_download for links to a file, and forms: true sends form_submit for each submitted form. The scope is the element's data-numbers-id, or the destination, file name or form id/action. numbers.formSubmit(form) sends one by hand. With the script, call numbers.autoTrack({ outbound: true }) after it loads; it replaces the script's own autoTrack, so nothing is counted twice.

Some events only the server knows, like a paid order: send those from a loader, an action or a webhook with an API token. See events from your server.

Limits

  • Names, scopes and other strings: at most 256 characters. Currency: at most 8 (EUR).
  • A request body: at most 8 KB.
  • Names starting with gtm. are refused: they are Google Tag Manager's own.
  • 300 events a minute per visitor's IP and Organization. After a 429 the SDK stops sending for the Retry-After, or a minute.

See what comes in

Events in the dashboard lists every name and scope the environment received in the range, with how often, from how many visitors and when last. It is the quickest way to check a new event, or whether an Improve test's goal arrives.

A test integration can leave events you don't want to keep. The same page has Delete events for admins and developers: without a visitor id it removes the range's events in the selected environment, for everyone; with one it removes that visitor's events and exposures in every environment and all time, for an erasure request. Either way it brings the event registry's counts back in step. A range for everyone leaves exposures alone, so a test's Monitor still lists visitors whose events you just deleted.

A deletion that is longer than one batch deletes what it can and asks you to submit again: the page says how many went and that more remain.

On this page

Marks in the margin

  • Note
  • Watch out
  • Updated

Scribes marked doubtful lines in the margin. That practice is called obelism.

Stuck on a step?