PXL Events
Integration
Import
import * as pxl from "@mod-consilio/js/pxl";
Send events
Send a pxl event:
pxl.sendPxlEvent("mymodule:myevent");
Send a pxl event with custom data (see Custom data fields below):
pxl.sendPxlEvent("mymodule:myevent", { ds_mystring: "some string", dn_mynumber: 1234 });
Options
Set the global options for all subsequent pxl calls:
let options = {};
pxl.setOptions(options);
The following options can be set in the options
object:
donottrack
: Set to"0"
or"1"
to explicitly allow resp. refuse tracking, or set to"unspecified"
, which means the browser's Do Not Track setting is used. Defaults to"0"
.recordurl
: Base url to which to send PXL events. Defaults to"/.px/"
.altsamplerate
: Sample rate for the alternative record url as a fraction of the number of events, for example, setting it to1/100
(or.01
) sends 1 in 100 events to the alternative record url. Defaults to0
(no sampling).altrecordurl
: Alternative record url. Defaults to"/.px/alt/"
.sessionexpiration
: The number of days the user id is valid. Defaults to30
.nobrowserenvironment
: Set to true to omit some browser context fields (bu
,bs
andbp
). This option can be used to reduce the length of the pxl url. Defaults tofalse
.debug
: Set totrue
to enable debugging in the JavaScript console. Defaults to the value of thepxl
dom debug flag.
To set specific options when sending pxl event, supply an options object to the sendPxlEvent call:
let options = {};
pxl.sendPxlEvent("mymodule:myevent", { ds_mystring: "some string", dn_mynumber: 1234 }, options);
PXL QUERY VARIABLES
Pxl event fields
Base pxl event fields, identifying the event, user and/or session.
pe
Pxl eventpi
User identifier, which is a permanent identifier for the user across browser sessions and valid for at most 30 daysps
User session id, which is tied to the current browsing session of the userpp
Page session id, which changes after each page loadpc
Event counter for this page session. 1-based.pr
Alternative record URL sample rate
Browser context fields
The actual referrer and browser identification for the page sending the event, along with some extra information about the browser environment. These might differ from the referrer and user agent in the access log if using a CDN.
bl
The current url (location) of the pagebr
The referrer, if knownbt
User agent triplet (platform-name-version)bd
Device type (one ofdesktop
,mobile
ortablet
), if knownbu
User agent stringbs
Screen size, if known (<width>x<height>
)bp
Device pixel ratio, if known
The last three fields (bu
, bs
and bp
) can be omitted if not wanted or if the url might become too large by setting the nobrowserenvironment
option.
Custom data fields
Fields containing custom data which can be used for analyzation of the events. XXX denotes a custom string consiting of a-z, 0-9 or underscores, eg 'ds_clientid'
ds_XXX
Text datadn_XXX
Number datadb_XXX
Flag data
PXL INDEXED FIELDS
Pxl event fields
pxl.event
Pxl event, the value of thepe
query variablepxl.userid
User identifier, the value of thepi
query variablepxl.sessionid
User session id, the value of theps
query variablepxl.pageid
Page session id, the value of thepp
query variablepxl.counter
Event counter for this page session, the value of thepc
query variablepxl.samplerate
Alternative record URL sample rate, the value of thepr
query variable
Browser context fields
pxl.location
The current url (location) of the page, the value of thebl
query variablepxl.referrer
The referrer, if known, the value of thebr
query variablepxl.user_agent.os
The user agent platform (one ofandroid
,ios
,linux
,mac
,webos
orwindows
), based on the value of thebt
query variablepxl.user_agent.name
The user agent browser name (one ofchrome
,edge
,firefox
,ie
,opera
orsafari
), based on the value of thebt
query variablepxl.user_agent.major
The user agent version, based on the value of thebt
query variablepxl.user_agent.device
Device type (one ofdesktop
,mobile
ortablet
), the value of thebd
query variablepxl.agent
User agent string, the value of thebu
query variablepxl.screen.width
Screen width, based on the value of thebs
query variablepxl.screen.height
Screen height, based on the value of thebs
query variablepxl.screen.pixelratio
Device pixel ratio, the value of thebp
query variable
Custom data fields
pxl.ds_XXX
Text data, the value of the correspodingds_XXX
query variablepxl.dn_XXX
Number data, the value of the correspodingdn_XXX
query variablepxl.db_XXX
Flag data, the value of the correspodingdb_XXX
query variable
General access log fields
pxl.remote_ip
Anonymized client IP addresspxl.url
Request URLpxl.method
Request method (e.g.GET
orPOST
)pxl.hostname
Request host namepxl.local_port
Request local port numberpxl.mime_type
Request MIME typepxl.body_received.bytes
Number of body bytes received from the clientpxl.response_code
Response code (e.g.200
or404
)pxl.body_sent.bytes
Number of body bytes sent to the clientpxl.duration.us
Duration of handling the request, in microsecondspxl.geoip.country_iso_code
Client physical location two-letter country code, based on the client IP addresspxl.geoip.location.lat
Client physical location latitude, based on the client IP addresspxl.geoip.location.lon
Client physical location longitude, based on the client IP addresspxl.geoip.region_name
Client physical location region name, based on the client IP addresspxl.geoip.city_name
Client physical location city name, based on the client IP address