Skip to content

Latest commit

 

History

History
59 lines (51 loc) · 8.29 KB

File metadata and controls

59 lines (51 loc) · 8.29 KB

Home > @snowplow/browser-tracker > BrowserTracker

BrowserTracker interface

The Browser Tracker

Signature:

interface BrowserTracker 

Properties

Property Type Description
addPlugin (configuration: BrowserPluginConfiguration) => void Add a plugin into the plugin collection after Tracker has already been initialised
clearUserData (configuration?: ClearUserDataConfiguration) => void Clears all cookies and local storage containing user and session identifiers
core TrackerCore The instance of the core library which this tracker has initialised
crossDomainLinker (crossDomainLinkerCriterion: (elt: HTMLAnchorElement | HTMLAreaElement) => boolean) => void Enable querystring decoration for links passing a filter
disableActivityTracking () => void Disables page activity tracking.
disableActivityTrackingCallback () => void Disables page activity tracking callback.
disableAnonymousTracking (configuration?: DisableAnonymousTrackingConfiguration) => void Disables 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) => void Strip braces from URL
discardHashTag (enableFilter: boolean) => void Strip hash tag (or anchor) from URL
enableActivityTracking (configuration: ActivityTrackingConfiguration) => void Enables page activity tracking (sends page pings to the Collector regularly).
enableActivityTrackingCallback (configuration: ActivityTrackingConfiguration & ActivityTrackingConfigurationCallback) => void Enables page activity tracking (replaces collector ping with callback).
enableAnonymousTracking (configuration?: EnableAnonymousTrackingConfiguration) => void Enables anonymous tracking (ie. tracker initialized without anonymousTracking)
flushBuffer (configuration?: FlushBufferConfiguration) => void Send all events in the outQueue Only need to use this when sending events with a bufferSize of at least 2
getCookieName (basename: string) => string Get the cookie name as cookieNamePrefix + basename + . + domain.
getDomainSessionIndex () => number Get the domain session index also known as current memorized visit count.
getDomainUserId () => string Get visitor ID (from first party cookie)
getDomainUserInfo () => ParsedIdCookie Get the visitor information (from first party cookie)
getPageViewId () => string Get the current page view ID
getTabId () => string | null Get the current browser tab ID
getUserId () => string | null | undefined Get the current user ID (as set previously with setUserId()).
id string The unique identifier of this tracker
namespace string The tracker namespace
newSession () => void Expires current session and starts a new session.
preservePageViewId () => void Stop regenerating pageViewId (available from web_page context)
preservePageViewIdForUrl (preserve: PreservePageViewIdForUrl) => void Decide 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) => void Alter buffer size Can be useful if you want to stop batching requests to ensure events start sending closer to event creation
setCollectorUrl (collectorUrl: string) => void Specify the Snowplow collector URL. Specific http or https to force it or leave it off to match the website protocol.
setCookiePath (path: string) => void Set first-party cookie path
setCustomUrl (url: string) => void Override url
setDocumentTitle (title: string) => void Override document.title
setOptOutCookie (name?: string | null) => void Sets the opt out cookie.
setReferrerUrl (url: string) => void Override referrer
setUserId (userId?: string | null) => void Set the business-defined user ID for this user.
setUserIdFromCookie (cookieName: string) => void Set the business-defined user ID for this user to the value of a cookie.
setUserIdFromLocation (querystringField: string) => void Set the business-defined user ID for this user using the location querystring.
setUserIdFromReferrer (querystringField: string) => void Set the business-defined user ID for this user using the referrer querystring.
setVisitorCookieTimeout (timeout: number) => void Set visitor cookie timeout (in seconds)
sharedState SharedState The instance of shared state this tracker is using
trackPageView (event?: PageViewEvent & CommonEventProperties) => void Log visit to this page
updatePageActivity () => void Triggers the activityHandler manually to allow external user defined activity. i.e. While watching a video