Skip to content

Latest commit

 

History

History
76 lines (65 loc) · 8.19 KB

File metadata and controls

76 lines (65 loc) · 8.19 KB

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(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
CommonEventProperties Additional data points to set when tracking an event
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
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
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
ContextPrimitive A context primitive is either a self-describing JSON or a context generator
SelfDescribingJson export interface for any Self-Describing JSON such as context or Self Describing events
TrackerConfiguration The configuration object for initialising the tracker