Retrieve all pages with last view date with total view count
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
Data on how often a page is viewed and whether it has been viewed recently can be valuable in a variety of situations, such as pruning old content. This article contains instructions for retrieving this information from the database.
Solution
The below query will retrieve the following data:
Total Views Per Page
Page Title
Space Name
Space Key
Latest Viewed Date/Time
Content ID
Always back up your data before making any database modifications. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
SELECT count (*) as "TOTAL_VIEWS_PER_PAGE",
c.title AS "PAGE_TITLE",
s.spacename AS "SPACE_NAME",
s.spacekey AS "SPACE_KEY",
max(to_timestamp(aoe."EVENT_AT" / 1000)::timestamp) AS "LATEST_VIEWEDTIME",
c.contentid AS "CONTENT_ID"
FROM "AO_7B47A5_EVENT" aoe
JOIN content c on aoe."CONTENT_ID" = c.contentid
JOIN spaces s on c.spaceid = s.spaceid
JOIN user_mapping um ON aoe."USER_KEY" = um.user_key
WHERE aoe."NAME" = 'page_viewed'
AND c.prevver is null
AND c.CONTENT_STATUS = 'current'
GROUP BY aoe."CONTENT_ID", c.spaceid, c.title, s.spacename, c.contentid, s.spacekey
ORDER BY s.spacename;
More Information
For a broader overview on retrieving content analytics and additional queries to pull similar data, please see the below article:
Was this helpful?