Skip to main content
Use the SDK in browser applications built with npm. It loads your exact Bily tracking URL, keeps early calls in order, and can be imported safely during server rendering.

Install Bily

New npm installs resolve the latest release. npm normally saves a compatible caret range unless your project changes that setting. A lockfile keeps existing builds reproducible; publishing a new SDK version does not rewrite a deployed bundle. The current stable release is 2.0.8. It waits for runtime initialization before resolving ready().

Start tracking once

Select your store. Then open Bily > Settings > Apps > More settings > Install tracking, choose your framework, and copy the exact scriptUrl from the SDK snippet.
analytics.ts
Import this module once from your browser entry point. This gives the SDK one clear place to start.
main.ts
Do not add a separate script tag. For this installation path, init() loads the script.

Let Bily track navigation

The browser script records the initial page and supported client-side navigation automatically. Do not add manual PageView calls for those navigations; use track() for business events.

Choose how SDK updates arrive

Use one installation path for the website surface.
  • Bundled npm applications: keep the compatible major range saved by your package manager, update the lockfile, test, rebuild, and redeploy to receive a new SDK release. Do not enable automatic breaking-major upgrades.
  • Browser modules without a bundler: the managed major-version URL below follows compatible 2.x releases as CDN and browser caches refresh on new page loads. An already-open page keeps its loaded code. This is not an immediate update guarantee.
  • Copied or uploaded SDK assets, including Shopify theme files: those bytes remain unchanged until you replace and redeploy them. They do not become managed merely because the npm package was updated.

Use the managed browser module

Use this instead of the npm initializer when the site supports browser modules and you want compatible CDN updates without rebuilding the SDK file. Do not also install a second raw Bily tracking script. Keep the exact customer tracking URL from Bily; the CDN module is only the SDK loader.
Keep @2 in the managed URL to avoid an automatic breaking-major change. Your content security policy must permit the selected CDN module and your exact Bily tracking URL. If you require immutable asset review or a fixed integrity hash, pin a specific release and manage updates explicitly instead of using this moving URL. The SDK’s in-memory queue is not durable delivery storage. Do not clear application-owned pending events or redirect solely because track() returned. Preserve consent and stable event IDs in your own retry or delivery contract.

Track successful actions

create-workspace.ts
Send completion events only after the operation succeeds. This keeps attempted actions from looking like completed ones.

Track custom events

Change the tracking URL