# Trying to understand pageviews

**URL:** <https://meta.discourse.org/t/trying-to-understand-pageviews/255130>\
**Category:** Data & reporting\
**Tags:** sql-query, dashboard-reports\
**Created:** [February 14, 2023, 4:08pm UTC](https://meta.discourse.org/t/trying-to-understand-pageviews/255130 "2023-02-14T16:08:11Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![michebs](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/michebs/32/190102_2.png) [@michebs](https://meta.discourse.org/u/michebs)\
**Post date:** [February 28, 2023, 3:26pm UTC](https://meta.discourse.org/t/trying-to-understand-pageviews/255130/7 "2023-02-28T15:26:54Z")

</div>

> [@ganncamp](#):
>
> I don’t know how to map the last two counts from my query, but even leaving them aside

Types of requests code 11 are those made by `API`, and requests code 12 are made by the `user API`.

> [@ganncamp](#):
>
> Versus the reporting on the admin homepage:
> 
> ![Selection_801](https://global.discourse-cdn.com/meta/original/4X/d/2/7/d2715154a7e06fad6912ca7cfa23d0ebdd1ec33d.png)

Activity Metrics consolidates `Logged in Users` (req\_type: 7), `Anonymous users` (req\_type: 8 ), and `Crawlers` (req\_type: 6). They are the same considered in the first chart of the Admin Panel “Consolidated Pageviews”.

Below is an example of the query for the Consolidated Pageviews Report

> **SQL Consolidated Pageviews**
>
> ```sql
> -- [params]
> -- date :start_date
> -- date :end_date
> 
> SELECT
> ar.date::date AS "date",
> CASE 
> WHEN ar.req_type=6 THEN 'Crawlers'
> WHEN ar.req_type=7 THEN 'Logged in users'
> WHEN ar.req_type=8 THEN 'Anonymous users'
> END user_type,
> SUM(ar.count) AS views
> FROM application_requests ar
> WHERE req_type IN (6,7,8)
> AND ar.date::date BETWEEN :start_date AND :end_date
> GROUP BY "date", user_type
> ORDER BY "date"
> 
> ```

> **SUM Consolidated Pageviews**
>
> ```sql
> -- [params]
> -- date :start_date
> -- date :end_date
> 
> SELECT
> ar.date::date AS "date",
> SUM(ar.count) AS pageviews
> FROM application_requests ar
> WHERE req_type IN (6,7,8)
> AND ar.date::date BETWEEN :start_date AND :end_date
> GROUP BY "date"
> ORDER BY "date" DESC
> 
> ```

---

_[View the full topic](https://meta.discourse.org/t/trying-to-understand-pageviews/255130)._
