Skip to the page

Developer GuideTracking

JavaScript API

Reference for the venbit() function, which reports leads, custom events, missing pages, form results, sign-ups and purchases from your own code.


The tracker adds a single global function, venbit(). Your own code calls it to report what the tracker can't see by itself, such as a lead, a named event, a missing page, the result of a form, a sign-up or a payment.

JavaScript
venbit('lead');
venbit('404');
venbit('event', 'pricing_viewed', { value: 5 });
venbit('signup', { name: 'Dana Whitfield', email: 'dana@harborroofing.example', plan: 'Free trial' });
venbit('subscribe', { value: 49, currency: 'USD', plan: 'Pro', id: 'sub_1042' });
venbit('purchase', { value: 129.5, currency: 'USD', id: 'order_8841' });
venbit('form_success', 'contact', { form: document.getElementById('contact') });
const url = venbit('link', 'https://app.harborroofing.example/signup');

Once the tracker line is on the page, the function exists. You'll find the line, with your site's key in place of KEY, in the dashboard under Settings, then Tracking.

HTML
<script defer crossorigin="anonymous" src="https://vnbt.app/m.js?s=KEY" data-site="KEY"></script>

venbit() never throws. Pass it arguments it doesn't understand and it does nothing.

Call it before the tracker loads

Because the tracker tag is deferred, an inline script or your app's first render can run ahead of it. Put this stub before your first call. Calls wait in venbit.q and get played back in order once the tracker loads.

HTML
<script>
  window.venbit = window.venbit || function () { (venbit.q = venbit.q || []).push(arguments); };
</script>
With the stub in place, early calls wait for the tracker

If the tracker never loads (behind an ad blocker, say), the stub also keeps your code from failing. If you'd rather skip it, guard each call instead:

JavaScript
window.venbit?.('event', 'pricing_viewed');

A queued call returns nothing. That only matters for venbit('link', url), covered below.

venbit('lead')

Marks a lead by hand, for a win that isn't a form, a phone tap or an email click. It's counted as a lead the same way a form send is, with no field values, and goes out at once.

JavaScript
venbit('lead');
venbit('lead', 'callback-requested');
ParameterTypeRequiredMeaning
labelstringNoA name for this lead. Defaults to manual.

Real forms should go through the form calls below, which keep what the visitor typed and run the normal spam checks. Accounts and payments have signup, subscribe and purchase.

venbit('404')

Reports the current page as missing.

JavaScript
venbit('404');

When your server answers with a 404 or 410 status, the page is reported automatically. You only need this call for a "not found" screen your app draws while the server answers 200. Each path is reported once per page load.

venbit('event', name, props)

Records a named event on the visit.

JavaScript
venbit('event', 'quote_calculator_used');
venbit('event', 'video_watched', { value: 75 });
ParameterTypeRequiredMeaning
namestringYesThe event's name, up to 80 characters.
props.valuenumberNoA number to store with the event. Anything that isn't a number is ignored.

You'll see the event as a step in the visitor's trail. Set a goal to match the event's name and it counts as a completion. Matching is on the whole name, ignoring case. Only value is kept. Any other key in props is dropped.

venbit('signup' | 'subscribe' | 'purchase', props)

Reports an account, the start of a paid plan, or a one-off payment. These go out at once.

JavaScript
venbit('signup', { name: 'Dana Whitfield', email: 'dana@harborroofing.example', plan: 'Free trial' });
venbit('subscribe', { value: 49, currency: 'USD', plan: 'Pro', email: 'dana@harborroofing.example', id: 'sub_1042' });
venbit('purchase', { value: 129.5, currency: 'USD', email: 'dana@harborroofing.example', id: 'order_8841' });
PropertyTypeMeaning
namestringWho it was. Up to 80 characters.
emailstringTheir email. Up to 160 characters.
planstringThe plan's name. Up to 60 characters.
valuenumberThe amount, in the currency given (49 or 49.99). Zero or more, rounded to two decimals.
currencystringA currency code such as USD.
idstring or numberYour own id for the order or account. Up to 64 characters. The same id is counted once.

All properties are optional. The calls feed the Sign-ups, Subscriptions and Purchases goals under Settings, then Goals. Pass a name or email and the Inbox shows who it was. For de-duplication, app mode and a full example, see Sign-ups and purchases.

When your code navigates to your other domain (say, from the marketing site to app.yoursite.com), this returns the address to send the visitor to. A sign-up over there then gets credited to the ad or page that brought them.

JavaScript
const target = 'https://app.harborroofing.example/signup';
window.location.href = window.venbit('link', target) || target;
ParameterTypeRequiredMeaning
urlstringYesWhere you're about to send the visitor.

If the host is one you listed under Settings, then Goals, as the place people sign up, you get the same address back with the visit attached. Any other address comes back as url, unchanged. Ordinary <a href> links to a listed host are handled without this call, so reach for it only in code that navigates by itself. The || target covers a call the stub queued, which returned nothing.

venbit('form_attempt' | 'form_success' | 'form_failure', formName, props)

Reports what happened to a form your code sends. Most forms are tracked automatically. For custom and JavaScript-drawn forms, these calls make the result exact.

JavaScript
const form = document.getElementById('contact');

venbit('form_success', 'contact', { form, submissionId: 'msg_20931' });
venbit('form_failure', 'contact', { form });
ParameterTypeRequiredMeaning
type'form_attempt', 'form_success' or 'form_failure'YesA send was started, it was accepted, or it was refused.
formNamestringNoWhich form: its data-venbit-form value, id or name. Ignored when props.form is given.
props.formElement or stringNoThe form element (or its container). The most reliable way to say which form.
props.valuesobjectNoField values as { Label: value }, for a form whose values aren't in the page's inputs.
props.submissionIdstringNoYour id for this submission. A result with the same id is counted once per page.

form_success records a sent form. If it's an enquiry form, that's a lead in the Inbox, carrying the values the tracker read from its fields plus any you pass. form_failure records a failed send, which isn't a lead. And form_attempt marks a send that has started, for forms with no ordinary submit button or submit event.

Leave out both formName and props.form and the call applies to the one form on the page with a send in progress. Form tracking has the details, including how a form is found by name.

Other names

Any other first argument gets recorded as a plain click, labelled with the second argument (or the name itself). If you want to build a goal on it, use venbit('event', name).

Calls you won't find

There's no identify call, so you can't attach your own user id to a visitor. signup, subscribe and purchase can carry a name and email for that one event.

Page views have no call either. They're counted automatically, single-page route changes included (see Single-page apps).

Opting out isn't a JavaScript call. A browser opts out by opening the site with ?vb_optout=1 on the address, and back in with ?vb_optout=0. See Privacy controls.

TypeScript

Drop this into a .d.ts file in your project (venbit.d.ts, for example).

A coding agent can also write the file for you. The prompt's version declares venbit as a global too, so bare venbit(...) calls type-check alongside window.venbit(...).

Add TypeScript types for the Venbit tracker's global venbit() function. Create venbit.d.ts with a Venbit interface of call signatures: ('lead', label?), ('404'), ('event', name, { value?: number }), ('signup' | 'subscribe' | 'purchase', { name, email, plan, value, currency, id }), ('link', url) returning string | undefined, and ('form_attempt' | 'form_success' | 'form_failure', formName?, { form, values, submissionId }), plus q?. Inside declare global, declare both interface Window { venbit: Venbit } and var venbit: Venbit. End with export {}.
TypeScript
type VenbitConversion = {
  name?: string;
  email?: string;
  plan?: string;
  value?: number;
  currency?: string;
  id?: string | number;
};

type VenbitFormResult = {
  form?: Element | string;
  values?: Record<string, string | number | boolean | Array<string | number>>;
  submissionId?: string;
};

interface Venbit {
  (type: 'lead', label?: string): void;
  (type: '404'): void;
  (type: 'event', name: string, props?: { value?: number }): void;
  (type: 'signup' | 'subscribe' | 'purchase', props?: VenbitConversion): void;
  (type: 'link', url: string): string | undefined;
  (
    type: 'form_attempt' | 'form_success' | 'form_failure',
    formName?: string,
    props?: VenbitFormResult
  ): void;
  q?: IArguments[];
}

declare global {
  interface Window {
    venbit: Venbit;
  }
}

export {};

Common questions

What happens if venbit() is called and the tracker is blocked?

When the tracker never loads (an ad blocker is the usual cause), venbit doesn't exist and a bare call fails. Add the queue stub before your first call, or guard each call with window.venbit?.(...). With the tracker loaded, venbit() never throws.

What data can I send with a Venbit custom event?

venbit('event', name, props) takes a name of up to 80 characters and an optional numeric props.value. Other keys in props are dropped, and a non-numeric value is ignored.

How do I turn a custom event into a goal in Venbit?

Set a goal to match the event's name. Matching is on the whole name and ignores case, so venbit('event', 'quote_calculator_used') completes a goal named quote_calculator_used.

Can I opt a visitor out of Venbit from JavaScript?

There's no venbit() call for it. A browser opts out by opening the site with ?vb_optout=1, or your code can set localStorage.setItem("vb_optout", "1") as shown in Privacy controls.

Last updated . Something wrong or missing on this page? Tell us from Settings, then Support.