Get Visualforce usage stats from VisualforceAccessMetrics


Posted on Aug 08, 2020


featured image
If you want to know how frequently your Visualforce pages are accessed, you just have to run a simple query on VisualforceAccessMetrics:
   
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:

   
SELECT Id, Markup, Name, NamespacePrefix 
FROM ApexPage 
WHERE Id IN (SELECT ApexPageId FROM VisualforceAccessMetrics)
  
Now the query will return only existing pages.
Photo by Kevin Ku on Unsplash

salesforce visualforce dev lightning
Search
Side Widget
You can put anything you want inside of these side widgets. They are easy to use, and feature the new Bootstrap 4 card containers!