- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Page views api endpoint returns empty array for all users
I am trying to retrieve page view information from the canvas API.
For Example: {{domain}}/api/v1/users/1/page_views
This request returns a 200 status but the response is an empty array `[]`
Is there some sort of setting I must activate in order for canvas to start collecting page views? Or perhaps a plugin of some kind that needs to be installed?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you sure that user 1 has any page views? Try viewing the page views for your account.
The token you're using should be good or you would be getting an authorized error, not an empty response. The same thing would happen if there was no user 1. However, if user 1 has never logged in and viewed pages, then it would be empty. I verified this behavior with a user that has never logged in on our site.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
User #1 is an account one that I have access to. I know that this user has signed on and viewed several different views in canvas, courses, pages, assignments, etc. Additionally my script loops through every user ID in my subaccount ID and checks for page_views. They all result in an empty array as response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Does this mean that you are running your own instance of Canvas as opposed to a hosted version? I don't have any experience there, so someone else will have to help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes the instance I am working with is self-hosted on AWS.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In hosted Canvas, the endpoint you specified seems to work just fine. I agree with @James that this is likely something pertaining to your self-hosted setup. Unfortunately, this means most of us won't be of much help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there anyone that can help? I am still waiting on a solution to why it would return empty array.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
One thing to check is that the user who is attempting to look at page views has permission to see statistics as otherwise you won't be able to see the page view. The documentation on this permission is here: https://community.canvaslms.com/t5/Canvas-Resource-Documents/Canvas-Account-Role-Permissions/ta-p/38...
There is a setting which is disabled by default called `enable_page_views` which you should enable. Instructure store page views in a cassandra DB in production, but I believe for self hosted instances it should also be possible to store the page views in the standard Canvas DB.
