cookies-initializer 1.4.0
Install from the command line:
Learn more about npm packages
$ npm install @finderau/cookies-initializer@1.4.0
Install via package.json:
"@finderau/cookies-initializer": "1.4.0"
About this version
This frontend JS module creates cookies used especially for tracking:
-
__futm_op
- bot flag -
__futm_source
- user's originalutm_source
param from the 1st visit recently -
__futm_session
- indicating user's active session -
__futm_data
- all the tracking data likeutm_source
,utm_medium
,utm_landing_page_id
etc. from query params and other sources of truth
The module exposes one main function to import from its index:
import { initCookies } from '@finderau/cookies-initializer';'
The function can be run with no arguments:
initCookies()
which will initialize cookies of __futm_data
, __futm_op
, __futm_session
and __futm_source
.
You can also pass it a partial or full configuration which is an object with any of the following properties:
initCookies({
additionalCookieCreators: CookieCreator[]; // handlers for your custom cookies
cookieAccess: CookieAccess; // your custom handler for cookie access, by default it just uses document.cookie directly
errorHandler: ErrorHandler; // your custom error handler, by default it goes to console.error
currentUrl: string; // customized currentUrl to assume in the app, default: window.location.href
searchEngines: string[]; // custom list of search engine keywords (e. g. "google", "bing" etc) to scan for in the referrer
referrer?: string; // custom referrer URL, by default: document.referrer
dataCookieName: string; // custom UTM data cookie name, default: __futm_data
dataEnabled: boolean; // whether to enable __futm_data cookie, default: true
sessionCookieName: string; // custom UTM session cookie name, default: "__futm_session"
sessionEnabled: boolean; // whether to enable __futm_session cookie, default: true
sourceCookieName: string; // custom UTM source cookie name, default: "__futm"
sourceEnabled: boolean; // whether to enable __futm cookie, default: true
botCookieName: string; // custom bot detection cookie name, default: "__futm_op"
botEnabled: boolean; // whether to use bot detection cookie, default: true
botTrapPaths: string[]; // paths which entered cause raising the bot cookie, default: [] (none)
internalUrlParamPrefix: string; // for replacing internal URL tracking params into UTM params, default: "futm_"
searchEngineUrlParamPrefix: string; // for replacing internal URL tracking params into UTM params, default: "utm_"
pageData: Partial<PageData>; // page data to store in the data cookie, by default - {} (no data)
})