function main (){ return Events({ from_date: "2023-04-06", to_date: "2023-05-26", event_selectors: [{event: "FeedExited"}, {event: "GameExited"}, {event: "DiscoveryExited"}] }) .filter(function(event){return event.properties.UserName && event.properties.InviteCode}) .groupBy(["properties.UserName", "properties.InviteCode"], mixpanel.reducer.count()); }
尝试了上面的代码,但它只返回三个事件的计数总和。
如果我理解正确的话,你想区分这些事件。 在这里,我添加了事件名称作为分组标准的一部分,这样您将获得每个“用户名”和“邀请代码”的每个事件的计数。
function main() {
return Events({
from_date: "2023-04-06",
to_date: "2023-05-26",
event_selectors: [
{event: "FeedExited"},
{event: "GameExited"},
{event: "DiscoveryExited"}
]
})
.filter(function(event) {
return event.properties.UserName && event.properties.InviteCode;
})
.groupBy(
["name", "properties.UserName", "properties.InviteCode"],
mixpanel.reducer.count()
);
}
这样你就可以得到像这样的json数据:
[
{"key": ["FeedExited", "user123", "codeABC"], "value": 5},
{"key": ["GameExited", "user123", "codeABC"], "value": 3},
{"key": ["DiscoveryExited", "user456", "codeXYZ"], "value": 7}
]