This function in a nutshell.
Think of
$p("send")
as a Google Analytics event tracking on analytics.js. In principle, you can track ANY custom events that you would like us to look into (click, engaged, bought, converted, and etc).
$p("send"): (String, Object) -> undefined
This function sends activity to our side. It takes in two additional arguments: the event name and context. For example:
$p("send", "engaged",{
FIELD1: "VALUE1",
FIELD2: "VALUE2"
})
$p('send', 'pageview', {
u_gender: "male",
u_type: "subscribed"
})
$p('send', 'conversion', {
u_gender: "male",
u_type: "subscribed"
})
// You can use context object to mark any additional information you want us to know about the event.
Invoking the function above sends an event with name engaged
. The object passed in as last argument is the context
object. If there's any custom information that you want to send over to our side, then you can specify it in the object.
Naughty Characters
Note that for Key-Value pair of events being sent, the key string should not contain a character that isn't allowed for a filename in standard Linux filesystem (i.e. ampersand, percent, and etc).
Any key field that contains such character will be filtered by our backend.
If you know that you'll be providing same context on every event, then you can set the globalCtx
when the script is initialized. Read this documentation to learn the basics of initializing our script with custom configurations.
When globalCtx
is set at initialization, then every event sent over to our side will have the information appended to it without you having to define it in context object of track or send.
var customConfig = {
globalCtx: {
gender: "male",
user_type: "logged_in"
}
}
$p("init", {JAVASCRIPT_KEY}, {config: customConfig}); // REPLACE JAVASCRIPT_KEY
$p("send", "pageview");