In our org we have a need to programmatically replicate the functionality of delivered “File Engagement” component/card.

Here is a snapshot from our live org, on a ContentDocument view page: https://i.sstatic.net/Fu8l1.png

Since this is from the live org, we assume that this component is using a delivered object, and counts the Views and Downloads.

We figured that ContentVersionHistory object actually holds the download details, and we can replicate the 'Downloads' number by counting the related rows with field = 'contentVersionDownloaded'. However, when we run the same SOQL query with only changing field = 'contentVersionViewed', we get 0 results. Not only for this specific contentVersionId, but any other contentVersionIds.

My question is, somehow, am I missing something in ContentVersionHistory, or is this information actually stored in a different object? Maybe in an aggregated form as view stat/count?

  • I ran the following in the dev console SELECT Id, ContentVersionId, ContentVersion.ContentDocumentId, CreatedDate,Field FROM ContentVersionHistory WHERE Field='contentVersionViewed' and got 8 results back. Now here is the odd bit... They are all from 2013-07. There isn't anything since then. I'm wondering if Salesforce changed the way they track views on Files. Commented Feb 25, 2021 at 23:44
  • Even though I am a System Administrator in our org, and have the special permission named "Query All Files", until I manually shared the specific file with my user, I was not able to query ContentVersionHistory. Nothing, not even the field = 'contentVersionDownloaded'. Only after I shared the file(s) manually, then I was able to query them off of ContentVersionHistory. Just in case.
    – kivanconer
    Commented Feb 26, 2021 at 6:26

2 Answers 2


Since the ContentVersionHistory isn't working I have an uneasy feeling that the way to get the information is from the EventLogFile for Content Transfer. This would likely be a paid feature to access that data.

The docs do indicate that the VersionRenditionDownload Transaction_Type would track the file previews, which agrees with the Spring '19 release notes on what counts as a view under the "File Engagement" control.

NOTE Only file types that display a preview are counted. Views and downloads through public links or content deliveries aren’t counted in the file engagement stats for files in the org. Reference

  • I have actually recently paid for the service to get the full EventLogFile. VersionRenditionDownload is there, yes, but it only displays a file was viewed. Not necessarily which file. I have confirmed with Salesforce support that it is the expected behavior.
    – kivanconer
    Commented Feb 26, 2021 at 6:29
  • It is really interesting that somehow "File Engagement" card is displaying the actual Views count by pulling from the live org, not from EventLogFile. I am thinking there must be a way... maybe SOQL level additional security or something (a total speculation on my part).
    – kivanconer
    Commented Feb 26, 2021 at 6:31

Try this solution:


    <aura:component description="test" implements="flexipage:availableForAllPageTypes" access="global">
    <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
    <aura:attribute name="statItems" access="global" type="Object[]"/>
    <aura:iteration items="{!v.statItems}" var="item">




    doInit : function (cmp, event, helper) {
        helper.doInitHelper(cmp, event, helper);


    doInitHelper : function (cmp, event, helper) {
        var currentStatItems = cmp.getReference("v.statItems");

            {recordId: '0697A000001IFebQAG',
                statItems: currentStatItems},
            function(newButton, status, errorMessage){
                if (status === "SUCCESS") {
                } else if (status === "INCOMPLETE") {
                    console.log("No response from server or client is offline.")
                } else if (status === "ERROR") {
                    console.log("Error: " + errorMessage);
  • Welcome to Salesforce Stack Exchange (SFSE)! Your contribution is welcome. But usually "code dump" answers are frowned upon on SFSE. I understand the original question was "How to replicate functionality?" and I assume that your code does that. But if there is any why it works helpful explanation you can add - however brief - to the how of your code, please edit your answer to add it.
    – Moonpie
    Commented Sep 6, 2022 at 16:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .