Aggregation by User Attribute
I'm working through the API documentation and have run into a snag. The body code below works perfectly for returning time-bound counts aggregated by the User's agent.
{
"response": {
"mimeType": "application/json"
},
"request": {
"name": "os-chart-count-by-browser",
"pipeline": [{
"source": {
"events": {
"eventClass": ["web", "ios"]
},
"timeSeries": {
"period": "dayRange",
"first": "now()",
"count": -30
}
}
}, {
"identified": "visitorId"
}, {
"group": {
"group": ["visitorId", "userAgent"]
}
}, {
"useragent": {
"userAgent": "userAgent"
}
}, {
"group": {
"group": ["userAgent.os"],
"fields": [{
"count": {
"count": null
}
}]
}
}, {
"select": {
"count": "count",
"os": "userAgent.os"
}
}, {
"sort": ["-count"]
}],
"requestId": "os-chart-count-by-browser"
}
}
What I'd like to do is to run the same type of query, but aggregate by visitor attributes. For instance, our visitors have language (
visitor.visitor_agent_language), agent attributes (visitor.userAgent_deviceType) and a bunch of custom visitor attributes like the user's permission group in our application (visitor.visitor_agent_userpermissiongroups_ap) that I'd like to return aggregate totals.
My desired result for something like that User Permissions attribute would be:
My desired result for something like that User Permissions attribute would be:
{
"startTime": 1682049600000,
"results": [
{
"AP Permissions": "Contributor",
"count": 4932
},
{
"AP Permissions": "Administrator",
"count": 55
},
{
"AP Permissions": "Read Only",
"count": 3
},
{
"AP Permissions": "None",
"count": 1
}
]
}
How would I construct the body of an Aggregate query to pull counts of page load events by these Visitor attributes?
1
Comments
This would return something like this (taken from my test account):
Oh my - so much to unpack here. First of all - this works perfectly so thank you so much! I had been digging through the Engage API documentation (https://engageapi.pendo.io/) and it is NOT easy to find the Operators documentation. With your code above, I was able to google up a cleaner description of that function here (https://adoptpartners.pendo.io/hc/en-us/articles/360043366692-API-Documentation#operators). Thank you again - you have cleared the clog!
Alisyn Collins - would it be possible to apply a filter to your query that only returned Event Counts (numEvents) greater than 0?
Aldric Delahaie, yes indeed! You'd want to just add a filter operator just before the select like this:
Please sign in to leave a comment.