Skip to Content
DevelopersSDKsWeb SDKAPI Reference

Web SDK Reference

Auto-generated from libs/web-sdk/src/ — version 1.14.1.

This reference is generated at build time from the SDK source code. Method signatures are always in sync with the latest published version.

Core methods (Aegis)

MethodSignatureDescription
initasync init(writeKey: string, config?: Partial<AegisConfig>): Promise<void>Initialize the SDK with your write key and optional config.
tracktrack(eventName: string, properties?: Record<string, any>): voidTrack a custom event with optional properties.
identifyidentify(userId: string, traits?: Record<string, any>): voidIdentify a user by ID and set traits (name, email, etc.).
pagepage(name?: string, properties?: Record<string, any>): voidTrack a page view. Called automatically if auto_page_view is enabled.
groupgroup(groupId: string, traits?: Record<string, any>): voidAssociate the current user with a group (company, account).
aliasalias(newUserId: string): voidMerge an anonymous session with an identified user ID.
resetreset(): voidClear the current user identity and start a fresh anonymous session.
flushasync flush(): Promise<void>Manually flush all queued events to the server.
getAnonymousId`getAnonymousId(): stringnull`
getUserId`getUserId(): stringnull`
getSessionId`getSessionId(): stringnull`
debugdebug(enable?: boolean): voidEnable or disable console debug logging.
useuse(plugin: Plugin): voidRegister a plugin for event transformation.
setWorkspacesetWorkspace(code: string): void(1.14.0) Pin the runtime workspace code; persists in sessionStorage.
clearWorkspaceclearWorkspace(): void(1.14.0) Clear the runtime workspace and remove the sessionStorage entry.
ingestWorkspaceCodesingestWorkspaceCodes(codes: string[]): void(1.14.0) Seed the workspace-code allowlist used for URL-path-segment resolution. Bootstrap fills this automatically.
getEffectiveWorkspaceIdgetEffectiveWorkspaceId(): string | undefined(1.14.0) Return the workspace ID resolved through the cascade (config → ?ws= → URL path → runtime → sessionStorage).
setConsentsetConsent(preferences: Partial<ConsentPreferences>): voidSet consent preferences (analytics, marketing, functional).
grantConsentgrantConsent(category?: ConsentCategory): voidGrant consent for a specific category or all categories.
denyConsentdenyConsent(category?: ConsentCategory): voidDeny consent for a specific category or all categories.
hasConsenthasConsent(category: ConsentCategory): booleanCheck if consent is granted for a specific category.
getConsentPreferences`getConsentPreferences(): ConsentPreferencesnull`
onConsentChangeonConsentChange(callback: (prefs: ConsentPreferences) => void): () => voidRegister a callback for consent preference changes. Returns an unsubscribe function.
destroydestroy(): voidTear down the SDK — flush events, clear timers, remove listeners.

E-commerce tracking (Aegis.ecommerce)

Access via Aegis.ecommerce.productViewed(...) after initialization.

MethodSignatureDescription
productViewedproductViewed(product: EcommerceProduct): voidTrack a product detail page view.
productListViewedproductListViewed(list: EcommerceProductList): voidTrack a product list/category view.
productClickedproductClicked(product: EcommerceProduct, source?): voidTrack a product click from a list.
searchPerformedsearchPerformed(search: EcommerceSearch): voidTrack a site search query.
addToCartaddToCart(product: EcommerceProduct): voidTrack an add-to-cart action.
removeFromCartremoveFromCart(product: EcommerceProduct): voidTrack a remove-from-cart action.
cartViewedcartViewed(cart: EcommerceCart): voidTrack a cart page view.
checkoutStartedcheckoutStarted(checkout: EcommerceCheckout): voidTrack checkout initiation.
orderCompletedorderCompleted(order: EcommerceOrder): voidTrack a completed order.
orderRefundedorderRefunded(orderId: string, value?: number): voidTrack an order refund.
couponAppliedcouponApplied(coupon: EcommerceCoupon): voidTrack a coupon/promo code application.
wishlistItemAddedwishlistItemAdded(wishlist: EcommerceWishlist): voidTrack adding an item to a wishlist.
promotionViewedpromotionViewed(promo: EcommercePromotion): voidTrack a promotion banner view.
promotionClickedpromotionClicked(promo: EcommercePromotion): voidTrack a promotion banner click.

Web Push (AegisWebPush)

Import from @active-reach/web-sdk/push.

MethodSignatureDescription
initializeasync initialize(): Promise<void>Initialize web push — registers service worker and checks permission.
requestPermissionasync requestPermission(): Promise<boolean>Request push notification permission from the user.
identifyasync identify(params: ContactIdentity): Promise<void>Associate the push subscription with a contact identity.
logoutasync logout(): Promise<void>Unlink the push subscription from the current user.

React integration

Import from @active-reach/web-sdk/react.

MethodSignatureDescription
AegisProviderReact.FC<{ writeKey, config, children }>React context provider — wraps your app and initializes the SDK.
useAegis(): AegisContextValueHook to access the SDK instance and user identity.
useTrackEvent(): (event: string, props?) => voidHook that returns a track() function bound to the current SDK instance.
usePageView(name?, props?, deps?) => voidHook that fires page() on mount and when dependencies change.
useIdentifyUser(): (userId: string, traits?) => voidHook that returns an identify() function bound to the current SDK instance.

Configuration options

Passed to Aegis.init(writeKey, config).

OptionTypeDefaultDescription
workspace_idstringRequiredYour workspace ID from Settings → Developer
api_hoststringAuto-detectedAPI endpoint — resolved per region automatically
preferred_regionstringAutoData residency region (IN, US, EU, APAC)
auto_region_detectionbooleantrueDetect region from Cloudflare headers
batch_sizenumber10Events per batch before sending
batch_intervalnumber1000Milliseconds between batch sends
capture_utmbooleantrueAuto-capture UTM parameters from URL
capture_referrerbooleantrueAuto-capture document referrer
auto_page_viewbooleanfalseAutomatically track page views on navigation
session_timeoutnumber30Session timeout in minutes
debugbooleanfalseEnable console debug logging
respect_dntbooleantrueHonor browser Do Not Track signal
cross_domain_trackingbooleanfalseEnable cross-domain user tracking
cookie_domainstringCurrent domainCookie domain for cross-subdomain tracking
secure_cookiebooleantrueSet Secure + HttpOnly flags on cookies
enable_offline_modebooleantrueQueue events when the browser is offline
max_offline_eventsnumber100Max queued events during offline mode
retry_failed_requestsbooleantrueAuto-retry failed event batches
max_retriesnumber3Max retry attempts per failed batch
retry_backoff_multipliernumber2Exponential backoff multiplier between retries
request_timeoutnumber5000HTTP request timeout in milliseconds
rate_limit_burstnumber100Client-side rate limiter — burst capacity (token bucket)
rate_limit_per_secondnumber20Client-side rate limiter — sustained tokens per second
wait_for_consentbooleanfalseDefer all event sending until consent is granted
enable_consent_modebooleanfalseEnable GDPR/CCPA consent mode
integrate_onetrustbooleanfalseAuto-integrate with OneTrust consent manager
integrate_cookiebotbooleanfalseAuto-integrate with Cookiebot consent manager
integrate_google_consent_modebooleanfalseAuto-integrate with Google Consent Mode v2
push.vapidPublicKeystringVAPID public key for Web Push subscription
push.autoPromptbooleanfalseAutomatically prompt for push permission
push.promptDelaynumber5000Delay in ms before auto-prompt appears
push.serviceWorkerPathstring'/aegis-sw.js'Path to the push service worker file

In-app messaging + widgets

The single entry point is AegisMessageRuntime. Construct once per page, call initialize(), swap identity with updateContactId(id), and tear down with destroy(). The runtime exposes the in-app and widget managers as readonly props — they are intentionally NOT barrel-exported.

import { AegisMessageRuntime } from '@active-reach/web-sdk'; const runtime = new AegisMessageRuntime({ /* config */ }); await runtime.initialize(); runtime.inApp.show('campaign_123'); runtime.widgets.render(/* widget config */); runtime.notifyConversion('checkout'); // G1 frequency_cap seam — also silences // journey-queued cart-recovery touches.

Campaign types (impression): modal, banner, tooltip, full_screen, half_interstitial, alert, pip.

Interactive: spin_wheel, scratch_card, nps_survey, quiz, countdown_offer, star_rating, quick_poll, multi_step_form.

Contextual: carousel_cards, sticky_bar, progress_bar, coachmark_tour, product_recommendation.

Placements

The AegisPlacementManager renders inline content in DOM slots. Content types: banner, card, carousel, video, html, dynamic_injection.

Register a placement slot: placementManager.register(placementId, { selector, contentType }).

Trigger engine

Client-side triggers that fire actions based on user behavior: scroll_depth, time_on_page, exit_intent, inactivity, scroll_velocity, visibility_change, back_button.


Last generated: 2026-04-17T08:57:03.098Z