I am using keen io Web Auto-Collection events like page views, clicks and form submission. I want to add custom parameters like user ID, Org ID, Org Name to these events. How can I do that?
Asked
Active
Viewed 148 times
2 Answers
2
Try using the extend events method to add additional properties to the events being sent with auto-collector.
// Extend events for a single collection
client.extendEvent('transaction', {});
client.extendEvent('transaction', function(){
return {};
});
// Extend events for all collections
client.extendEvents({});
client.extendEvents(function(){
return {};
});
// Example usage
var userProps = {
full_name: 'User Dude',
email: 'name@domain.com',
id: 'f1233423h',
username: 'userdude213'
};
// Include a predefined 'user' object with every purchase event
client.extendEvent('purchases', {
'user': userProps
});
// Include a predefined 'user' object with every event
client.extendEvents({
'user': userProps
});
// Include a dynamic 'keen.timestamp' property with every event
client.extendEvents(function(){
return {
keen: {
timestamp: new Date().toISOString()
}
};
});

Michelle Wetzler
- 734
- 4
- 16
1
This is a little snippet that I'm using to push extended data into Keen IO Web Auto-Collection:
window.keenWebAutoCollector.onload(function(){
var userProps = {
username : "Any given username",
uid : 123,
other: "data"
};
window.keenWebAutoCollector.tracker.extendEvents({
'user': userProps
});
});
This snippet needs to be added after the code for the Auto-Collector (https://keen.io/docs/streams/web-auto-collection/).
And it will augment the user
property for all the collections events triggered by the Auto-Collector (Pageviews, Clicks and Form Submissions).

Pekastel
- 241
- 2
- 7