Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time

Home > @snowplow/browser-tracker

browser-tracker package

Functions

Function Description
addGlobalContexts(contexts, trackers) All provided contexts will be sent with every event
addPlugin(configuration, trackers) Add a plugin into the plugin collection after trackers have already been initialised
clearGlobalContexts(trackers) Clear all global contexts that are sent with events
clearUserData(configuration, trackers) Clears all cookies and local storage containing user and session identifiers
crossDomainLinker(crossDomainLinkerCriterion, trackers) Enable querystring decoration for links pasing a filter
disableAnonymousTracking(configuration, trackers) 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(enable, trackers) Strip braces from URL
discardHashTag(enable, trackers) Strip hash tag (or anchor) from URL
enableActivityTracking(configuration, trackers) Enables page activity tracking (sends page pings to the Collector regularly).
enableActivityTrackingCallback(configuration, trackers) Enables page activity tracking (replaces collector ping with callback).
enableAnonymousTracking(configuration, trackers) Enables anonymous tracking (ie. tracker initialized without anonymousTracking)
flushBuffer(configuration, trackers) Send all events in the outQueue Only need to use this when sending events with a bufferSize of at least 2
newSession(trackers) Expires current session and starts a new session.
newTracker(trackerId, endpoint) Initialise a new tracker
newTracker(trackerId, endpoint, configuration) Initialise a new tracker
preservePageViewId(trackers) Stop regenerating pageViewId (available from web_page context)
removeGlobalContexts(contexts, trackers) All provided contexts will no longer be sent with every event
setBufferSize(newBufferSize, trackers) Set the buffer size Can be useful if you want to stop batching requests to ensure events start sending closer to event creation
setCollectorUrl(collectorUrl, trackers) Specify the Snowplow collector URL. Specific http or https to force it or leave it off to match the website protocol.
setCookiePath(path, trackers) Set first-party cookie path
setCustomUrl(url, trackers) Override url
setDocumentTitle(title, trackers) Override document.title
setOptOutCookie(name, trackers) Sets the opt out cookie.
setReferrerUrl(url, trackers) Override referrer
setUserId(userId, trackers) Set the business-defined user ID for this user.
setUserIdFromCookie(cookieName, trackers) Set the business-defined user ID for this user to the value of a cookie.
setUserIdFromLocation(querystringField, trackers) Set the business-defined user ID for this user using the location querystring.
setUserIdFromReferrer(querystringField, trackers) Set the business-defined user ID for this user using the referrer querystring.
setVisitorCookieTimeout(timeout, trackers) Set visitor cookie timeout (in seconds)
trackPageView(event, trackers) Track a visit to a web page
trackSelfDescribingEvent(event, trackers) Track a self-describing event happening on this page. A custom event type, allowing for an event to be tracked using your own custom schema and a data object which conforms to the supplied schema
trackStructEvent(event, trackers) Track a structured event A classic style of event tracking, allows for easier movement between analytics systems. A loosely typed event, creating a Self Describing event is preferred, but useful for interoperability.
updatePageActivity(trackers) Triggers the activityHandler manually to allow external user defined activity. i.e. While watching a video

Interfaces

Interface Description
ActivityTrackingConfiguration The base configuration for activity tracking
ActivityTrackingConfigurationCallback The callback for enableActivityTrackingCallback
BrowserPlugin Interface which defines Core Plugins
BrowserPluginConfiguration The configuration of the plugin to add
BrowserTracker The Browser Tracker
ClearUserDataConfiguration The configuration that can be changed when enabling anonymous tracking
CommonEventProperties Additional data points to set when tracking an event
ContextEvent Argument for ContextGenerator and ContextFilter callback
DisableAnonymousTrackingConfiguration The configuration that can be changed when disabling anonymous tracking
EnableAnonymousTrackingConfiguration The configuration that can be changed when enabling anonymous tracking
FlushBufferConfiguration The configuration that can be changed when flushing the buffer
PageViewEvent A Page View event Used for tracking a page view
RuleSet A ruleset has accept or reject properties that contain rules for matching Iglu schema URIs
SelfDescribingEvent A Self Describing Event A custom event type, allowing for an event to be tracked using your own custom schema and a data object which conforms to the supplied schema
StructuredEvent A Structured Event A classic style of event tracking, allows for easier movement between analytics systems. A loosely typed event, creating a Self Describing event is preferred, but useful for interoperability.

Variables

Variable Description
version

Type Aliases

Type Alias Description
ActivityCallback The callback for enableActivityTrackingCallback
ActivityCallbackData The data which is passed to the Activity Tracking callback
AnonymousTrackingOptions
ConditionalContextProvider Conditional context providers are two element arrays used to decide when to attach contexts, where: - the first element is some conditional criterion - the second element is any number of context primitives
ContextFilter A context filter is a user-supplied callback that is evaluated for each event to determine if the context associated with the filter should be attached to the event
ContextGenerator A context generator is a user-supplied callback that is evaluated for each event to allow an additional context to be dynamically attached to the event
ContextPrimitive A context primitive is either a self-describing JSON or a context generator
CookieSameSite
EventMethod
FilterProvider A filter provider is a tuple that has two parts: a context filter and the context primitive(s) If the context filter evaluates to true, the tracker will attach the context primitive(s)
Platform
RuleSetProvider A ruleset provider is aa tuple that has two parts: a ruleset and the context primitive(s) If the ruleset allows the current event schema URI, the tracker will attach the context primitive(s)
SelfDescribingJson export interface for any Self-Describing JSON such as context or Self Describing events
StateStorageStrategy
TrackerConfiguration The configuration object for initialising the tracker