Database Query that can display more than the OOTB top ten users who accessed (Space Activity) (hit/clicked on/viewed) a space or page.
Asked by Benjamin Weeks:

Greetings and sorry for the horrible description from before. Is there a database query that can display more than just the top ten "Most popular content (views) for a site or space? "/spaces/usage/report.action?key=bwp" Currently it will display the top ten most popular content but I was trying to take a particualar space and/or page and have a list of user names and the number of times they visited, hit, or viewed that particular space or page. Maybe if the script could be ran once a month for a particular space/page to return the desired data?

Thanks!


Answers:
author: David Simpson
body: *OK, so you're interested in analytics?*

*As @Thomas Alfred replied in a [previous question](/questions/227205/is-there-any-way-confluence-can-tell-us-how-many-hits-a-page-gets)...*

AppFusions' [Google Analytics plugin for Confluence](http://www.appfusions.com/display/GANLC/Home) is a good way of tracking page views and displaying the resultys within Confluence - it also displays results for external websites too.

Atlassian blogged about it a couple of times:
> [Measure Your Wiki's Activity with Google Analytics for Confluence](https://blogs.atlassian.com/2011/11/measure-your-wikis-activity-with-google-analytics-for-confluence/) and [Report Confluence Activity Using Google Analytics in the Wiki](http://blogs.atlassian.com/2009/12/report_confluence_activity_using_google_analytics_in_the_wiki/)

It's still fully supported despite no longer being listed in Atlassian's marketplace.

More details information on who is doing what (edit, view, delete, comment etc) can be found using [Mixpanel Engagement Analytics for Confluence](http://www.appfusions.com/display/CONFENGAGE/Home) also by our friends at AppFusions.

Just something to note, if you're tracking usernames or user's actual names using Google Analytics, you could have your Google Analytics account suspended as it's against section 7 of Google's terms of service. David Simpson gives a robust explanation of this in his blogpost:
> [Identifying your users in Google Analytics while complying with section 7 of the terms of service](http://davidsimpson.me/2013/10/17/identifying-your-users-in-google-analytics-while-complying-with-section-7-of-the-terms-of-service/)

One more thing, beware adding tracking code to At the end of the HEAD if you're also using **Zen Foundation** - this doens't work as they disable that functionality. Stick your stuff **At the end of the BODY** instead.


author: Benjamin Weeks
body: Hi, the article is from 2005, is there anything more up to date and has there not been very many people requesting more statistical data options for pages and spaces to monitor who and how often their spaces are visited?

Thanks.


author: Bob Swift (personal)
body: Not specifically to your question, but [Site Statistics](https://confluence.atlassian.com/display/DISC/Site+Statistics) does have some queries along the lines of understanding contributions and contributors on your site.


author: Benjamin Weeks
body: Is there a way to replicate what the out of the box function does to collect top ten hits but to make it for all hits over a particular time range? Could you find the code that gathers this content for display? With the hope of replicating it but to a wider range in time and users.


author: David Simpson
body: What do you mean by "top 10 users"? What is the criteria?


Tags: analytics