Skip to main content

Install the Website SDK

The JourneyLayer Website SDK is a single <script> tag. It auto‑tracks page views and exposes JourneyLayer.track() / identify() / reset() for your own events. No build step, no npm install.

1. Copy your snippet

Open Settings → SDK / Install in the dashboard. The Web tab shows a snippet pre‑baked with your Project Public ID and publishable browser token:

<script src="https://cdn.journeylayer.com/p/<PROJECT_PUBLIC_ID>/jl-script.js" async></script>

If you've set up a first‑party tracker domain, the snippet uses that host instead (e.g. https://track.yourdomain.com/p/…), which improves deliverability past ad‑blockers.

2. Add it to your site

Paste the snippet inside <head> (or just before </body>) on every page. On most sites you add it once to a shared header/footer template. That's it — the bundle initializes itself on load and creates a global JourneyLayer.

3. Verify it works

  1. Open your site, then DevTools → Console. Type JourneyLayer and press Enter — you should see an object, not ReferenceError.
  2. DevTools → Network: reload and confirm a POST …/v1/events returns 202.
  3. In JourneyLayer → Profiles / Find People, your visit appears within ~5–10 seconds.
Page views are automatic

You don't need to call anything for page views — the SDK fires a pageview event on load and on SPA route changes. See Auto pageview & the tracking API.

What loads

The hosted bundle is small and cached for ~5 minutes (with stale‑while‑revalidate), so rotating your publishable token takes effect for visitors within a few minutes. It captures device + UTM context automatically and batches events in the background.

Next