Get Visualforce usage stats from VisualforceAccessMetrics

photo of scenic beach resort
Reading Time: < 1 minutes

If you’re an administrator of a Salesforce org, you need to know how your users are interacting with your Visualforce pages. With Salesforce VisualforceAccessMetrics, you can easily get usage stats for your Visualforce pages and track page performance.

VisualforceAccessMetrics is a tool that lets you see which Visualforce pages are being accessed, how long users are staying on the page, and the page performance status. The data from VisualforceAccessMetrics can be used to optimize page performance and provide a better user experience.

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

More options

SELECT ApexPageId, MetricsDate, TotalTime, AverageTime, TotalRequests, UniqueUsers
FROM VisualforceAccessMetrics
WHERE MetricsDate = TODAY

Have in mind 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.

,

About the author

Andrés Canavesi
Andrés Canavesi

Software Engineer with 15+ experience in software development, specialized in Salesforce, Java and Node.js.


Related posts


Leave a Reply

%d bloggers like this: