I am trying to use the API to get real user counts per application. I have tried the following but it isn't matching what the console is showing. Can someone shed some light on this? It seems I am getting a fraction of the userids and some of the ones that are anon it is returning those as 'null'
select usersession.userid FROM usersession where usersession.userType = 'REAL_USER' AND useraction.application = 'My Awesome Application' GROUP BY usersession.userid
Solved! Go to Solution.
Yes I was able to get it to return the data although if I tell it to give me the count of userids in the query, the number doesn't match the user count from the User session console. I am thinking I don't have a filter or it is ignoring the timeframe filter because each time I run the query the number changes.
Query I am trying:
startTimestamp=1556733966561&endTimestamp=1556737361768&query=select count(userid) FROM usersession where usersession.userType = 'REAL_USER' AND useraction.application = 'My Awesome App' LIMIT 5000
The USQL and User Sessions API only work for completed/finished sessions, whereas the in-UI User Sessions page will also show "Live"/in-progress sessions.
If your timestamp is recent enough, this could be the reason why you are seeing differences.
Yes, I set the startime to be 0 so that it will give me the last 2 hours and I changed the UI to show me the last 2 hours? I am trying to get the unique users that have access my website in the last hour. The same data that shows up when I click on the User Sessions in the UI. You are saying though that the API will only give me the completed correct? I am just trying to get a count of how many users have been to my website in the last 2 hours. So this would be the count of users that have completed sessions and current live users.
Is there any way in the API to get live session data? If I am only counting completed sessions, I am not really getting the true count of users that have been or are still on the website in the last 2 hours. The UI gives me this information.
Thank you for that information! What I probably will end up doing is just checking the numbers once a day at a time when there shouldn't be much traffic on the website. That at least will give me a good ball park of users that used the system during the day.