Skip to main content

browser-tracker.browsertracker

Home > @snowplow/browser-tracker > BrowserTracker

BrowserTracker interface

The Browser Tracker

Signature:
interface BrowserTracker 

Properties

PropertyTypeDescription
addPlugin(configuration: BrowserPluginConfiguration) => voidAdd a plugin into the plugin collection after Tracker has already been initialised
clearUserData(configuration?: ClearUserDataConfiguration) => voidClears all cookies and local storage containing user and session identifiers
coreTrackerCoreThe instance of the core library which this tracker has initialised
crossDomainLinker(crossDomainLinkerCriterion: (elt: HTMLAnchorElement | HTMLAreaElement) => boolean) => voidEnable querystring decoration for links passing a filter
disableActivityTracking() => voidDisables page activity tracking.
disableActivityTrackingCallback() => voidDisables page activity tracking callback.
disableAnonymousTracking(configuration?: DisableAnonymousTrackingConfiguration) => voidDisables anonymous tracking if active (ie. tracker initialized with anonymousTracking) For stateStorageStrategy override, uses supplied value first, falls back to one defined in initial config, otherwise uses cookieAndLocalStorage.
discardBrace(enableFilter: boolean) => voidStrip braces from URL
discardHashTag(enableFilter: boolean) => voidStrip hash tag (or anchor) from URL
enableActivityTracking(configuration: ActivityTrackingConfiguration) => voidEnables page activity tracking (sends page pings to the Collector regularly).
enableActivityTrackingCallback(configuration: ActivityTrackingConfiguration & ActivityTrackingConfigurationCallback) => voidEnables page activity tracking (replaces collector ping with callback).
enableAnonymousTracking(configuration?: EnableAnonymousTrackingConfiguration) => voidEnables anonymous tracking (ie. tracker initialized without anonymousTracking)
flushBuffer(configuration?: FlushBufferConfiguration) => voidSend all events in the outQueue Only need to use this when sending events with a bufferSize of at least 2
getCookieName(basename: string) => stringGet the cookie name as cookieNamePrefix + basename + . + domain.
getDomainSessionIndex() => numberGet the domain session index also known as current memorized visit count.
getDomainUserId() => stringGet visitor ID (from first party cookie)
getDomainUserInfo() => ParsedIdCookieGet the visitor information (from first party cookie)
getPageViewId() => stringGet the current page view ID
getTabId() => string | nullGet the current browser tab ID
getUserId() => string | null | undefinedGet the current user ID (as set previously with setUserId()).
idstringThe unique identifier of this tracker
namespacestringThe tracker namespace
newSession() => voidExpires current session and starts a new session.
preservePageViewId() => voidStop regenerating pageViewId (available from web_page context)
preservePageViewIdForUrl(preserve: PreservePageViewIdForUrl) => voidDecide how the pageViewId should be preserved based on the URL. If set to false, the pageViewId will be regenerated on the second and each following page view event (first page view doesn't change the page view ID since tracker initialization). If set to true or 'full', the pageViewId will be kept the same for all page views with that exact URL (even for events tracked before the page view event). If set to 'pathname', the pageViewId will be kept the same for all page views with the same pathname (search params or fragment may change). If set to 'pathnameAndSearch', the pageViewId will be kept the same for all page views with the same pathname and search params (fragment may change). If preservePageViewId is enabled, the preservePageViewIdForUrl setting is ignored. Defaults to false.
setBufferSize(newBufferSize: number) => voidAlter buffer size Can be useful if you want to stop batching requests to ensure events start sending closer to event creation
setCollectorUrl(collectorUrl: string) => voidSpecify the Snowplow collector URL. Specific http or https to force it or leave it off to match the website protocol.
setCookiePath(path: string) => voidSet first-party cookie path
setCustomUrl(url: string) => voidOverride url
setDocumentTitle(title: string) => voidOverride document.title
setOptOutCookie(name?: string | null) => voidSets the opt out cookie.
setReferrerUrl(url: string) => voidOverride referrer
setUserId(userId?: string | null) => voidSet the business-defined user ID for this user.
setUserIdFromCookie(cookieName: string) => voidSet the business-defined user ID for this user to the value of a cookie.
setUserIdFromLocation(querystringField: string) => voidSet the business-defined user ID for this user using the location querystring.
setUserIdFromReferrer(querystringField: string) => voidSet the business-defined user ID for this user using the referrer querystring.
setVisitorCookieTimeout(timeout: number) => voidSet visitor cookie timeout (in seconds)
sharedStateSharedStateThe instance of shared state this tracker is using
trackPageView(event?: PageViewEvent & CommonEventProperties) => voidLog visit to this page
updatePageActivity() => voidTriggers the activityHandler manually to allow external user defined activity. i.e. While watching a video