【问题标题】:How to calculate DAU/MAU using Application Insights Analytics?如何使用 Application Insights Analytics 计算 DAU/MAU?
【发布时间】:2017-07-24 03:51:22
【问题描述】:

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

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?有人加入魔法?

【问题讨论】:

    标签: azure-application-insights ms-app-analytics


    【解决方案1】:

    编辑:

    现在calculate usage metrics 有一个更简单的方法 - “评估活动参与度”:

    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。

    几周前我写了一篇文章详细说明了如何计算stickiness in app analytics - 诀窍是你必须使用 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
    

    【讨论】:

    • 滚动粘性!星期一会试一试=)
    【解决方案2】:

    看起来这个查询可以做到:

    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
    

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

    【讨论】:

      【解决方案3】:

      Zaki,您的查询计算了一个时间点 MAU/DAU。如果您需要滚动 MAU,您可以使用 Asaf 建议的 HLL 方法。或者以下是我使用 make-series 和 fir() 的首选滚动 MAU。您可以在 using this link 到分析演示门户上动手玩。 这两种方法都需要一些时间来适应……而且据我所见,这两种方法都非常快。 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
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2023-01-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-05-26
        • 1970-01-01
        相关资源
        最近更新 更多