# Dashboard Report - Anonymous

**URL:** <https://meta.discourse.org/t/dashboard-report-anonymous/289114>\
**Category:** Data & reporting\
**Tags:** sql-query, dashboard-reports, dashboard-sql\
**Created:** [December 18, 2023, 10:55pm UTC](https://meta.discourse.org/t/dashboard-report-anonymous/289114 "2023-12-18T22:55:32Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![SaraDev](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/saradev/32/335139_2.png) [@SaraDev](https://meta.discourse.org/u/SaraDev)\
**Post date:** [December 18, 2023, 10:55pm UTC](https://meta.discourse.org/t/dashboard-report-anonymous/289114/1 "2023-12-18T22:55:32Z")

</div>

This is an SQL version of the Dashboard Report for Anonymous.

This report shows the number of pageviews a site has received each day from anonymous users (users who are not logged into an account) over a specified date range.

```sql
--[params]
-- date :start_date = 2023-12-01
-- date :end_date = 2024-01-01

SELECT 
    date, 
    SUM(count) AS pageviews
FROM
    application_requests
WHERE
    req_type = 8
    AND date BETWEEN :start_date AND :end_date
GROUP BY
    date
ORDER BY
     date

```

### SQL Query Explanation

- **Parameter Definition** : The query starts by defining two parameters, `:start_date` and `:end_date`, which are used to filter the data to the desired time frame. Both date parameters accept the date format of `YYYY-MM-DD` .
- **Data Selection** : It selects two columns, `date` and the sum of `count`, which is aliased as `pageviews`. The `count` represents the number of pageviews for each record.
- **Data Source** : The data is sourced from the `application_requests` table, which logs various types of requests made to the application.
- **Filtering** : The `WHERE` clause filters records to include only those that are of type `page_view_anon` (`req_type = 8`) and fall within the specified date range.
- **Aggregation** : The `GROUP BY` clause groups the results by the `date` column, which allows the `SUM` function to calculate the total pageviews for each date.
- **Sorting** : Finally, the results are ordered by the `date` in ascending order, providing a chronological view of the anonymous pageviews.

### Example Results

| date | pageviews |
| --- | --- |
| 2023-12-01 | 12345 |
| 2023-12-02 | 11346 |
| 2023-12-03 | 18344 |
| 2023-12-04 | 15344 |
| 2023-12-05 | 12890 |
| … | … |

### Notes on `req_type`

The `req_type` column in the `application_requests` table categorizes the type of request. In this query, we are interested in `req_type = 8` , which corresponds to anonymous pageviews.

Other `req_type` values represent different kinds of requests, such as crawler page views, logged in page views, and various HTTP response statuses.

_All `req_type` Values:_

```plaintext
0. http_total
1. http_2xx
2. http_background
3. http_3xx
4. http_4xx
5. http_5xx
6. page_view_crawler
7. page_view_logged_in
8. page_view_anon
9. page_view_logged_in_mobile
10. page_view_anon_mobile
11. api
12. user_api

```

---

_[View the full topic](https://meta.discourse.org/t/dashboard-report-anonymous/289114)._
