Bearing

Help · Use Bearing

Events from your server: count what the browser does not send

A sign-up or an order your server knows about is counted even when the visitor's browser sent nothing, and joins the visit it came from when it can.

An event sent by a page depends on the visitor's browser. A blocker, or a browser driven by a program, sends nothing: the account is created on your side, and the goal stays where it was. Your server knows the account exists. It can say so to Bearing itself. This is for a developer.

Set it up

  1. Open AI access, then Keys, and create a key For your site's server. It only sends events and reads nothing. Keep it on your server, never in a page.
  2. In the page, when the visitor does the action, take the visit token and send it to your server with the rest of your form. The token is made in the page's memory, is never stored on the visitor's device, and only lets an event join the visit it happened in.
  3. On your server, once the action is done, post the event to Bearing with the key and the token.
// In the page, with your form:
const token = window.bearing && window.bearing.token ? window.bearing.token() : "";
curl -X POST https://bearingstats.com/api/v1/events \
  -H "Authorization: Bearer bst_…" \
  -H "Content-Type: application/json" \
  -d '{"site": "example.com", "name": "signup", "token": "…", "id": "…"}'
  • site: your site's domain, or its identifier.
  • name: the event's name, as the Events tab shows it under Install and settings. An event that is not in your list yet shows as Detected.
  • token: what bearing.token() returned. Leave it out when the page had none (the script was blocked).
  • props: details, as for an event sent by a page (up to 30 short values). Never personal data.
  • id: optional, your own reference for this action. The same one is counted once, so a retry never counts twice. Bearing only keeps a fingerprint of it.

How it is counted

  • With a token Bearing knows, the event joins its visit: the conversion gets that visit's source and campaign, even if your server confirms it later. If the page also sends the event, the visit still counts as one conversion, but the Events tab counts two receptions: once your server confirms an event, stop sending it from the page.
  • Without a token, or with one Bearing never received because the browser sent nothing, the event is counted with no measured visit. It is in the goal's number and in the chart; it has no source and is not in the conversion rate. Bearing says how many there are, which is the size of what browsers did not tell it.
  • Each event counts toward your plan, like one sent by a page.
  • Pages viewed cannot be sent this way: a server does not make a visit.

What Bearing answers

Unlike the script, your server holds a key, so the answer says what happened:

{ "counted": true, "visit": true }     the event joined its visit
{ "counted": true, "visit": false }    counted, with no measured visit
{ "counted": false, "test": true }     a try: see below
{ "counted": false, "duplicate": true } this id was already received

An error comes with a sentence that says what to change: 401 for a missing or revoked key, 404 for a site that is not in your account, 400 for a message Bearing cannot read, 429 when too much arrives at once.

Try it without changing your numbers

Do the action from a browser where you excluded your own visits. That browser's token says so, and what your server sends with it is a try: nothing is counted, the answer says test, and the event shows try received in the Events tab. You then know the whole path works, from the page to your server to Bearing.

Payments do not go through here: connect Stripe and Bearing reads them itself.