How to Retrieve Content Analytics Information from the Database
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
Purpose
It can be useful to retrieve content analytics data directly from the database in case you want to inspect or manipulate the information externally. Some examples for this include identifying how many times a page has been viewed recently, the most recent date a page was viewed, or which actions have been taken on a page.
Solution
Analytics data and settings are stored in the following tables:
public | AO_7B47A5_EVENT | table | admin
public | AO_7B47A5_EVENT_ID_seq | sequence | admin
public | AO_7B47A5_SETTINGS | table | admin
public | AO_7B47A5_SETTINGS_ID_seq | sequence | admin
The AO_7B47A5_EVENT table is used to store each of the events, so the following query will retrieve all of them:
select * from "AO_7B47A5_EVENT";
If looking for a specific type of event, the NAME column can be used. Here is an example for page views:
select * from "AO_7B47A5_EVENT" where "NAME" = 'page_viewed';
Data Retention job history
The analytics functionality has two data retention strategies to contain its footprint on the database, more details here. To check the execution history of those jobs, we can use the following queries:
Data retention period (deletion based on date):
select * from scheduler_run_details where job_id = 'com.addonengine.analytics.DataRetention';
Event retention (deletion based on event count):
select * from scheduler_run_details where job_id like 'AnalyticsForConfluence.EventLimiter';