3

假设我有一个用户的定义,我可以计算所有每日用户和所有每月用户的总和。

customEvents
| where timestamp > ago(30d)
| where <condition>
| summarize by <user>, bin(timestamp, 1d)
| summarize count() by bin(timestamp, 1d)
| summarize DAU=sum(count_)

customEvents
| where timestamp > ago(30d)
| where <condition>
| summarize by <user>
| MAU=30*count

问题是如何计算 DAU/MAU?有的加入魔法?

4

3 回答 3

3

编辑:

现在有一种更简单的方法来计算使用指标- “评估 activity_engagement”:

union *
| where timestamp > ago(90d)
| evaluate activity_engagement(user_Id, timestamp, 1d, 28d)
| project timestamp, Dau_Mau=activity_ratio*100 
| render timechart

--------

DAU 在 Analytics 中非常直接 - 只需使用 dcount。

棘手的部分当然是计算 28 天的滚动 MAU。

几周前我写了一篇文章,详细说明了如何计算应用程序分析中的粘性——诀窍是你必须使用 hll() 和 hll_merge() 来计算每天的中间 dcount 结果,然后将它们合并在一起。

最终结果如下所示:

let start=ago(60d);
let period=1d;
let RollingDcount = (rolling:timespan)
{
pageViews
| where timestamp > start
| summarize hll(user_Id) by bin(timestamp, period)
| extend periodKey = range(bin(timestamp, period), timestamp+rolling, period)
| mvexpand periodKey
| summarize rollingUsers = dcount_hll(hll_merge(hll_user_Id)) by todatetime(periodKey)
};
RollingDcount(28d)
| join RollingDcount(0d) on periodKey
| where periodKey < now() and periodKey > start + 28d
| project Stickiness = rollingUsers1 *1.0/rollingUsers, periodKey
| render timechart
于 2017-03-05T09:36:18.750 回答
0

看起来这个查询是这样做的:

let query = customEvents
| where timestamp > datetime("2017-02-01T00:00:00Z") and timestamp < datetime("2017-03-01T00:00:00Z") 
| where **<optional condition>**;
let DAU = query
| summarize by **<user>**, bin(timestamp, 1d)
| summarize count() by bin(timestamp, 1d)
| summarize DAU=sum(count_), _id=1;
let MAU = query
| summarize by **<user>**
| summarize MAU=count(), _id=1;
DAU | join (MAU) on _id
| project ["DAU/MAU"] = todouble(DAU)/30/MAU*100, ["Sum DAU"] = DAU, ["MAU"] = MAU

有什么建议如何计算过去几个月的吗?

于 2017-03-03T23:35:35.547 回答
0

Zaki,您的查询计算了一个时间点 MAU/DAU。如果您需要滚动 MAU,您可以使用 Asaf 建议的 HLL 方法。或者以下是我首选的使用 make-series 和 fir() 的滚动 MAU。您可以使用此分析演示门户的链接亲自体验它。这两种方法都需要一些时间来适应……而且据我所见,这两种方法都非常快。make-series 和 fir() 方法的一个优点是它是 100% 准确的,而 HLL 方法是启发式的并且有一定程度的错误。另一个好处是,配置使用户有资格获得计数的用户参与度非常容易。

let endtime=endofday(datetime(2017-03-01T00:00:00Z));
let window=60d;
let starttime=endtime-window;
let interval=1d;
let user_bins_to_analyze=28;
let moving_sum_filter=toscalar(range x from 1 to user_bins_to_analyze step 1 | extend v=1 | summarize makelist(v)); 
let min_activity=1;
customEvents
| where timestamp > starttime  
| where customDimensions["sourceapp"]=="ai-loganalyticsui-prod"
| where (name == "Checkout")  
| where user_AuthenticatedId <> ""
| make-series UserClicks=count() default=0 on timestamp in range(starttime, endtime-1s, interval) by user_AuthenticatedId
// create a new column containing a sliding sum. Passing 'false' as the last parameter to fir() prevents normalization of the calculation by the size of the window.
| extend RollingUserClicks=fir(UserClicks, moving_sum_filter, false)
| project User_AuthenticatedId=user_AuthenticatedId , RollingUserClicksByDay=zip(timestamp, RollingUserClicks)
| mvexpand RollingUserClicksByDay
| extend Timestamp=todatetime(RollingUserClicksByDay[0])
| extend RollingActiveUsersByDay=iff(toint(RollingUserClicksByDay[1]) >= min_activity, 1, 0)
| summarize sum(RollingActiveUsersByDay) by Timestamp
| where Timestamp > starttime + 28d
| render timechart
于 2017-03-05T11:56:21.097 回答