Script tag
The IIFE build of @pivolio/browser exposes a global named
Pivolio and drains any commands you queued before it finished loading. Use it
on a CMS, a landing page builder, or anywhere you can’t run a bundler.
Install
The @1 in the URL pins the major version, so you get patches and features
without a breaking change landing unannounced.
Two names, two different things
Pivolio (capital P) is the API object, available only after the script has
loaded. window.pivolio (lowercase) is the command queue — a plain array.
Calling pivolio.track(...) will throw, because an array has no track method.
window.pivolio— an array youpush()command tuples onto. Safe to use before the script loads. This is the whole point of the queue: you can record a purchase on a page where the script is still in flight and it will replay.Pivolio— the real API, with every export as a method. Only safe after the script has loaded.
The async queue
Push a tuple of [method, ...args]. On load, the bundle walks the queue in order
and replays each command:
Note that track takes its arguments as separate queue elements —
['track', name, data] — and that properties stay nested under properties,
exactly as in the module API.
What replays, and what doesn’t
The pattern is straightforward: the queue replays commands, not queries.
A getter pushed onto the queue has nowhere to return its value to, so it is
silently ignored — no error, no console warning. Everything in the right-hand
column works fine on the Pivolio global once loaded.
reset is replayable, but remember it also destroys the singleton. If you push
['reset'] you must push another ['init', config] after it, or nothing will
track. See the browser SDK warning.
Direct global usage
Once the script has loaded, skip the queue and call the global:
To do this safely from a page that loads the bundle with async, hook the
script’s load event rather than guessing at the timing:
The two styles mix freely. Queue what you can before load, then use the global
for getters and for flush().
The IIFE bundle also exposes the Tracker class and the StandardEventName,
ConsentStatus and DeviceType enums. It does not expose the version export —
if you need the version at runtime, use the npm package.
Next steps
- Browser SDK — the full method surface.
- Configuration — every option you can pass to
init. - First-party domains — serve the collector from your own subdomain to beat ad-blockers.