BeaconDocsDashboard

Reference

Tag reference

Everything the tag understands, on one page.

Commands

Every command goes through the one global function, beacon(command, …), and returns a promise. Calls made before the tag loads are queued by the snippet's first line and run in order once it arrives. Unknown commands are ignored. A function passed as the last argument is called with the answer too.

CallWhat it does
beacon('event', name, props?)Records a custom event, with optional properties.
beacon('identify', userId)Links this browser's visits to your ID for the user. Remembered in this browser.
beacon('reset')Forgets the user and visitor IDs and starts a fresh anonymous visitor. Use on sign-out.
beacon('set', props)Adds properties to every event from now on, for the current page. Merges with earlier calls.
beacon('consent', { analytics })Records the visitor's answer when the tag has data-consent="required".
beacon('flush')Sends queued events now instead of within the next few seconds.
await beacon('variant', key)The visitor's variant in a running experiment, or null. Records an exposure once per visit.
await beacon('flag', key)Whether a feature flag is on for this visitor: true or false.
await beacon('value', key, fallback)This visitor's live value, or the fallback if the key doesn't exist or Beacon can't be reached.

Attributes

data-consent="required"On the tag's script element: store nothing beyond the tab until beacon('consent'). See Consent.
data-beacon-ignoreOn any element: left out of click tracking and session replay. See Session replay.

Automatic events

EventWhenProperties
$pageviewEvery page load and single-page navigation.title
$clickA click on a link or button (not inside data-beacon-ignore).tag, text, href (no query string), outbound
$pageleaveThe page is hidden or closed.pageview_id, engaged_ms, max_scroll_pct
$identifybeacon('identify') is called.—
$exposurebeacon('variant') first gives a visitor a variant, once per visit.experiment, variant

Every event also carries the page path (never the query string or fragment) and anything set with beacon('set').

Limits

  • Event names: letters, numbers and _ . : -, up to 63 characters. Other names are dropped.
  • Properties: up to 4 KB of JSON per event. Larger ones are replaced with a marker saying they were cut.
  • Event times come from the browser, corrected for its clock, and are kept within the last seven days.

Visitors and visits

  • A visitor is a browser, recognised by a random ID in a first-party cookie (_bk) and local storage, kept up to 400 days.
  • A visit (session) ends after 30 minutes without activity. Arriving from a new campaign link starts a new one.