Quick Start
The minimum setup is a single call. The Time on Page plugin auto-registers with sensible defaults — you don’t wire anything by hand.
import { AnalyticsBrowser } from "@adpharm/silo-analytics";
// The minimum setup — one call, the Time on Page plugin auto-registers with// sensible defaults (Silo CDN, event gateway, writeKey-namespaced storage).export const analytics = AnalyticsBrowser.load({ writeKey: "your-write-key", env: window.env.PUBLIC_APP_ENV, // optional — namespaces storage keys per env});Defaults applied internally
Section titled “Defaults applied internally”With just writeKey (+ optional env), the library fills in:
cdnURL→https://cdn.silo.adpharm.digitaltimeOnPage.apiHost→https://event-gateway.silo.adpharm.digital/v1/ttimeOnPage.writeKey→ inherits from the top-levelwriteKey- Storage keys →
ajs_user_id_${writeKey}_${env}andajs_user_traits_${writeKey}_${env}(no suffix ifenvis omitted)
Customizing
Section titled “Customizing”Pass anything you want to override. timeOnPage is Partial<> — only the
fields you set change; the rest keep their defaults.
import { AnalyticsBrowser } from "@adpharm/silo-analytics";
// Override anything you want to customize. `timeOnPage` is `Partial<>` — only// the fields you set are overridden; apiHost + writeKey still default.export const analytics = AnalyticsBrowser.load({ writeKey: "your-write-key", env: "production", cdnURL: "https://your-cdn.example.com", // override the Silo CDN default timeOnPage: { minSeconds: 10, // partial override; apiHost + writeKey still default maxSeconds: 1800, // cap events at 30m instead of the 900s default idleSeconds: 60, // pause engagement after 60s of no input (0 disables) eventName: "Engagement", // beacon event name (default "Page Time Spent") heartbeatSchedule: [60, 120, 240], // custom backoff (false disables) scrollTracking: false, // opt out of scroll-depth fields }, user: { cookie: { key: "custom_cookie_key" } }, // full override});See Configuration for every option, its type, and default.
SPA route changes
Section titled “SPA route changes”In a single-page app, fire analytics.page() on every client-side route change
(the standard Segment integration pattern). The plugin listens for those page
events — plus browser back/forward via popstate — to roll the page_view_id
and reset the engagement window per view. Without it, a whole SPA session looks
like one long page-view.