Posted on Aug 08, 2020
SELECT ApexPageId,DailyPageViewCount,Id,MetricsDate FROM VisualforceAccessMetrics
That query will return stats from the latest 90 days
Pageviews are tallied the day after the page is viewed, and each VisualforceAccessMetrics object is removed after 90 days.
But beware, that query could return deleted pages.
To fix that, let’s tweak the query to:
Now the query will return only existing pages.
SELECT Id, Markup, Name, NamespacePrefix FROM ApexPage WHERE Id IN (SELECT ApexPageId FROM VisualforceAccessMetrics)