# 统计用户（非工作人员、非爬虫）的页面浏览量

**URL:** <https://meta.discourse.org/t/counting-pageviews-for-users-non-staff-non-crawler/157071>\
**Category:** Data & reporting\
**Created:** [2020 年7 月 7 日 19:24 UTC](https://meta.discourse.org/t/counting-pageviews-for-users-non-staff-non-crawler/157071 "2020-07-07T19:24:14Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

作者： ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)\
发布日期： [2020 年7 月 7 日 19:47 UTC](https://meta.discourse.org/t/counting-pageviews-for-users-non-staff-non-crawler/157071/2 "2020-07-07T19:47:40Z")

</div>

该查询看起来应该能正常工作。

> [@mrjn](#):
>
> 它会考虑匿名浏览吗？

是的，按当前写法，它会统计匿名浏览。对于匿名主题浏览，`user_id` 将为 `NULL`，而 `ip_address` 将不为 `NULL`。您可以通过在查询中添加以下条件来排除匿名浏览：

```sql
AND user_id IS NOT NULL

```

> [@mrjn](#):
>
> 有没有办法将其转换为报告？

这可以通过插件实现。Discourse Solved 插件会在管理仪表板中添加一份报告。该插件中可能有一些代码可作为如何添加报告的示例：[discourse-solved/plugin.rb at main · discourse/discourse-solved · GitHub](https://github.com/discourse/discourse-solved/blob/master/plugin.rb#L320%E3%80%82)

---

_[View the full topic](https://meta.discourse.org/t/counting-pageviews-for-users-non-staff-non-crawler/157071)._
