Time Per User Per Book / Per Chapter #1552

Closed
opened 2026-02-05 01:12:52 +03:00 by OVERLORD · 7 comments
Owner

Originally created by @thebiggeek on GitHub (Feb 23, 2020).

Bookstack is an amazing tool and we have started to use it to setup our document repository so that people have access to it commonly. At Times as an Administrator / Senior Trainer in my team, I would like to see how many times a book has been accessed (Book Stats / Page Stats) and I would also like to see how much time Per book has been accessed / Chapter / Page - so that we can evaluate what kind of content works best.

I would also like to see a page that shows some kind of a leader board, as well as user statistics
Top Readers
Top Contributors
Per Chapter User Reading Analytics [Has Read, Spent xxx minutes etc]

Originally created by @thebiggeek on GitHub (Feb 23, 2020). Bookstack is an amazing tool and we have started to use it to setup our document repository so that people have access to it commonly. At Times as an Administrator / Senior Trainer in my team, I would like to see how many times a book has been accessed (Book Stats / Page Stats) and I would also like to see how much time Per book has been accessed / Chapter / Page - so that we can evaluate what kind of content works best. I would also like to see a page that shows some kind of a leader board, as well as user statistics Top Readers Top Contributors Per Chapter User Reading Analytics [Has Read, Spent xxx minutes etc]
Author
Owner

@ssddanbrown commented on GitHub (Mar 6, 2020):

Hi @thebiggeek,
Thank you for your positive feedback in addition to your recommendation.

To be honest, I probably wouldn't look to have such tracking features built-in to BookStack, at least for a while, especially since such metrics lean towards potential gamification. In addition, view-time tracking could be hard to capture accurately.

I do want to expand the in-system reporting and stats but these will likely be high-level admin based stats.

BookStack does already store view counts per page/chapter/book, per user, in addition to a range of activity. You could hook-up a business intelligence tool, Like Microsoft Power Bi, to the database to create your own reports based on this data. Alternatively, you could utlise an external analytics platform such as Matomo which appears to do view-time tracking.

@ssddanbrown commented on GitHub (Mar 6, 2020): Hi @thebiggeek, Thank you for your positive feedback in addition to your recommendation. To be honest, I probably wouldn't look to have such tracking features built-in to BookStack, at least for a while, especially since such metrics lean towards potential gamification. In addition, view-time tracking could be hard to capture accurately. I do want to expand the in-system reporting and stats but these will likely be high-level admin based stats. BookStack does already store view counts per page/chapter/book, per user, in addition to a range of activity. You could hook-up a business intelligence tool, Like Microsoft Power Bi, to the database to create your own reports based on this data. Alternatively, you could utlise an external analytics platform such as [Matomo](https://matomo.org/behaviour/) which appears to do view-time tracking.
Author
Owner

@thebiggeek commented on GitHub (Mar 7, 2020):

Thank you for the input @ssddanbrown and for creating this lovely tool. It has solved a big problem - earlier we were using a lot of CMS's to publish our learning material including a Complex one such as MODX - but you made my life simpler.

I understand that from a distant point of view, too many analytics will only move away from Book stack in terms of what it is. I also appreciate you giving me inputs on the stats focus you have for the future (looking forward to those) and for the Stats you mentioned. I am not sure I have seen those stats, so am going to look around.

Matomo / Microsoft Power BI - Indeed are great tools, let me see how I can do it.

@thebiggeek commented on GitHub (Mar 7, 2020): Thank you for the input @ssddanbrown and for creating this lovely tool. It has solved a big problem - earlier we were using a lot of CMS's to publish our learning material including a Complex one such as MODX - but you made my life simpler. I understand that from a distant point of view, too many analytics will only move away from Book stack in terms of what it is. I also appreciate you giving me inputs on the stats focus you have for the future (looking forward to those) and for the Stats you mentioned. I am not sure I have seen those stats, so am going to look around. Matomo / Microsoft Power BI - Indeed are great tools, let me see how I can do it.
Author
Owner

@thebiggeek commented on GitHub (Mar 7, 2020):

How do I access the stats for "BookStack does already store view counts per page/chapter/book, per user, in addition to a range of activity. " @ssddanbrown

@thebiggeek commented on GitHub (Mar 7, 2020): How do I access the stats for "BookStack does already store view counts per page/chapter/book, per user, in addition to a range of activity. " @ssddanbrown
Author
Owner

@ssddanbrown commented on GitHub (Mar 7, 2020):

@thebiggeek You'll need to use something to connect to your MySQL database (MySQL workbench, datagrip etc..).

The per-asset per-user views are stored in a views table:

select * from views limit 10;
+----+---------+-------------+---------------------+-------+---------------------+---------------------+
| id | user_id | viewable_id | viewable_type       | views | created_at          | updated_at          |
+----+---------+-------------+---------------------+-------+---------------------+---------------------+
|  1 |       1 |           1 | BookStack\Bookshelf |    96 | 2019-05-05 21:30:40 | 2020-02-02 21:40:33 |
|  2 |       1 |           1 | BookStack\Book      |   215 | 2019-05-05 21:48:46 | 2020-02-02 21:58:40 |
|  3 |       1 |           1 | BookStack\Chapter   |    26 | 2019-05-05 21:49:56 | 2019-09-27 20:31:12 |
|  4 |       1 |           1 | BookStack\Page      |    77 | 2019-05-05 21:53:13 | 2019-08-26 14:36:40 |
|  5 |       1 |           2 | BookStack\Page      |    10 | 2019-05-05 21:53:30 | 2019-09-28 11:32:34 |
|  6 |       1 |           3 | BookStack\Page      |    12 | 2019-05-05 21:53:49 | 2020-02-02 21:58:38 |
|  7 |       3 |           1 | BookStack\Page      |     1 | 2019-05-05 21:57:19 | 2019-05-05 21:57:19 |
|  8 |       3 |           1 | BookStack\Book      |    25 | 2019-05-05 21:57:24 | 2019-09-28 17:25:45 |
|  9 |       3 |           2 | BookStack\Chapter   |    17 | 2019-05-05 21:58:07 | 2019-10-02 21:25:26 |
| 10 |       3 |           4 | BookStack\Page      |     3 | 2019-05-05 21:59:27 | 2019-05-05 22:46:05 |
+----+---------+-------------+---------------------+-------+---------------------+---------------------+

Other activity can be found in the activities table:

select * from activities limit 10;
+----+------------------+-------+---------+---------+-----------+---------------------+---------------------+---------------------+
| id | key              | extra | book_id | user_id | entity_id | entity_type         | created_at          | updated_at          |
+----+------------------+-------+---------+---------+-----------+---------------------+---------------------+---------------------+
|  1 | bookshelf_create |       |       0 |       1 |         1 | BookStack\Bookshelf | 2019-05-05 21:30:40 | 2019-05-05 21:30:40 |
|  2 | book_create      |       |       1 |       1 |         1 | BookStack\Book      | 2019-05-05 21:48:46 | 2019-05-05 21:48:46 |
|  3 | bookshelf_update |       |       0 |       1 |         1 | BookStack\Bookshelf | 2019-05-05 21:48:46 | 2019-05-05 21:48:46 |
|  4 | book_update      |       |       1 |       1 |         1 | BookStack\Book      | 2019-05-05 21:48:56 | 2019-05-05 21:48:56 |
|  5 | chapter_create   |       |       1 |       1 |         1 | BookStack\Chapter   | 2019-05-05 21:49:56 | 2019-05-05 21:49:56 |
|  6 | page_create      |       |       1 |       1 |         1 | BookStack\Page      | 2019-05-05 21:53:13 | 2019-05-05 21:53:13 |
|  7 | page_create      |       |       1 |       1 |         2 | BookStack\Page      | 2019-05-05 21:53:30 | 2019-05-05 21:53:30 |
|  8 | page_create      |       |       1 |       1 |         3 | BookStack\Page      | 2019-05-05 21:53:49 | 2019-05-05 21:53:49 |
|  9 | chapter_create   |       |       1 |       3 |         2 | BookStack\Chapter   | 2019-05-05 21:58:07 | 2019-05-05 21:58:07 |
| 10 | page_create      |       |       1 |       3 |         4 | BookStack\Page      | 2019-05-05 21:59:27 | 2019-05-05 21:59:27 |
+----+------------------+-------+---------+---------+-----------+---------------------+---------------------+---------------------+
@ssddanbrown commented on GitHub (Mar 7, 2020): @thebiggeek You'll need to use something to connect to your MySQL database (MySQL workbench, datagrip etc..). The per-asset per-user views are stored in a `views` table: ```mysql select * from views limit 10; +----+---------+-------------+---------------------+-------+---------------------+---------------------+ | id | user_id | viewable_id | viewable_type | views | created_at | updated_at | +----+---------+-------------+---------------------+-------+---------------------+---------------------+ | 1 | 1 | 1 | BookStack\Bookshelf | 96 | 2019-05-05 21:30:40 | 2020-02-02 21:40:33 | | 2 | 1 | 1 | BookStack\Book | 215 | 2019-05-05 21:48:46 | 2020-02-02 21:58:40 | | 3 | 1 | 1 | BookStack\Chapter | 26 | 2019-05-05 21:49:56 | 2019-09-27 20:31:12 | | 4 | 1 | 1 | BookStack\Page | 77 | 2019-05-05 21:53:13 | 2019-08-26 14:36:40 | | 5 | 1 | 2 | BookStack\Page | 10 | 2019-05-05 21:53:30 | 2019-09-28 11:32:34 | | 6 | 1 | 3 | BookStack\Page | 12 | 2019-05-05 21:53:49 | 2020-02-02 21:58:38 | | 7 | 3 | 1 | BookStack\Page | 1 | 2019-05-05 21:57:19 | 2019-05-05 21:57:19 | | 8 | 3 | 1 | BookStack\Book | 25 | 2019-05-05 21:57:24 | 2019-09-28 17:25:45 | | 9 | 3 | 2 | BookStack\Chapter | 17 | 2019-05-05 21:58:07 | 2019-10-02 21:25:26 | | 10 | 3 | 4 | BookStack\Page | 3 | 2019-05-05 21:59:27 | 2019-05-05 22:46:05 | +----+---------+-------------+---------------------+-------+---------------------+---------------------+ ``` Other activity can be found in the `activities` table: ```mysql select * from activities limit 10; +----+------------------+-------+---------+---------+-----------+---------------------+---------------------+---------------------+ | id | key | extra | book_id | user_id | entity_id | entity_type | created_at | updated_at | +----+------------------+-------+---------+---------+-----------+---------------------+---------------------+---------------------+ | 1 | bookshelf_create | | 0 | 1 | 1 | BookStack\Bookshelf | 2019-05-05 21:30:40 | 2019-05-05 21:30:40 | | 2 | book_create | | 1 | 1 | 1 | BookStack\Book | 2019-05-05 21:48:46 | 2019-05-05 21:48:46 | | 3 | bookshelf_update | | 0 | 1 | 1 | BookStack\Bookshelf | 2019-05-05 21:48:46 | 2019-05-05 21:48:46 | | 4 | book_update | | 1 | 1 | 1 | BookStack\Book | 2019-05-05 21:48:56 | 2019-05-05 21:48:56 | | 5 | chapter_create | | 1 | 1 | 1 | BookStack\Chapter | 2019-05-05 21:49:56 | 2019-05-05 21:49:56 | | 6 | page_create | | 1 | 1 | 1 | BookStack\Page | 2019-05-05 21:53:13 | 2019-05-05 21:53:13 | | 7 | page_create | | 1 | 1 | 2 | BookStack\Page | 2019-05-05 21:53:30 | 2019-05-05 21:53:30 | | 8 | page_create | | 1 | 1 | 3 | BookStack\Page | 2019-05-05 21:53:49 | 2019-05-05 21:53:49 | | 9 | chapter_create | | 1 | 3 | 2 | BookStack\Chapter | 2019-05-05 21:58:07 | 2019-05-05 21:58:07 | | 10 | page_create | | 1 | 3 | 4 | BookStack\Page | 2019-05-05 21:59:27 | 2019-05-05 21:59:27 | +----+------------------+-------+---------+---------+-----------+---------------------+---------------------+---------------------+ ```
Author
Owner

@thebiggeek commented on GitHub (Mar 7, 2020):

Thanks this is helpful. Where can I find the View Details, as in who all has viewed it

@thebiggeek commented on GitHub (Mar 7, 2020): Thanks this is helpful. Where can I find the View Details, as in who all has viewed it
Author
Owner

@ssddanbrown commented on GitHub (Mar 7, 2020):

@thebiggeek The views table has a user_id column, which is the unique ID of a user, from the users table, that the row relates to. You'd need to use that ID to join data. For example:

select users.name, users.email, views.viewable_id, views.viewable_type,
views.views from views LEFT JOIN users on views.user_id = users.id limit 10;
+-------+-----------------+-------------+---------------------+-------+
| name  | email           | viewable_id | viewable_type       | views |
+-------+-----------------+-------------+---------------------+-------+
| Admin | admin@admin.com |           1 | BookStack\Bookshelf |    96 |
| Admin | admin@admin.com |           1 | BookStack\Book      |   215 |
| Admin | admin@admin.com |           1 | BookStack\Chapter   |    26 |
| Admin | admin@admin.com |           1 | BookStack\Page      |    77 |
| Admin | admin@admin.com |           2 | BookStack\Page      |    10 |
| Admin | admin@admin.com |           3 | BookStack\Page      |    12 |
| Dan   | danb@danb.me    |           1 | BookStack\Page      |     1 |
| Dan   | danb@danb.me    |           1 | BookStack\Book      |    25 |
| Dan   | danb@danb.me    |           2 | BookStack\Chapter   |    17 |
| Dan   | danb@danb.me    |           4 | BookStack\Page      |     3 |
+-------+-----------------+-------------+---------------------+-------+

@ssddanbrown commented on GitHub (Mar 7, 2020): @thebiggeek The `views` table has a `user_id` column, which is the unique ID of a user, from the `users` table, that the row relates to. You'd need to use that ID to join data. For example: ```mysql select users.name, users.email, views.viewable_id, views.viewable_type, views.views from views LEFT JOIN users on views.user_id = users.id limit 10; +-------+-----------------+-------------+---------------------+-------+ | name | email | viewable_id | viewable_type | views | +-------+-----------------+-------------+---------------------+-------+ | Admin | admin@admin.com | 1 | BookStack\Bookshelf | 96 | | Admin | admin@admin.com | 1 | BookStack\Book | 215 | | Admin | admin@admin.com | 1 | BookStack\Chapter | 26 | | Admin | admin@admin.com | 1 | BookStack\Page | 77 | | Admin | admin@admin.com | 2 | BookStack\Page | 10 | | Admin | admin@admin.com | 3 | BookStack\Page | 12 | | Dan | danb@danb.me | 1 | BookStack\Page | 1 | | Dan | danb@danb.me | 1 | BookStack\Book | 25 | | Dan | danb@danb.me | 2 | BookStack\Chapter | 17 | | Dan | danb@danb.me | 4 | BookStack\Page | 3 | +-------+-----------------+-------------+---------------------+-------+ ```
Author
Owner

@ssddanbrown commented on GitHub (Jul 12, 2020):

Since no further details were requested upon my last message I'll close this off

@ssddanbrown commented on GitHub (Jul 12, 2020): Since no further details were requested upon my last message I'll close this off
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#1552