Try our conversational search powered by Generative AI!

Track PDF views and downloads


I am using EpiServer profile store to track page views which is all good. How would i go about tracking PDF's and its downloads using the profile store. 

Edited, Jan 06, 2021 16:45

Hi Dileep,

To track views of PDFs, I think you'll need to call some custom tracking (as described here: when the PDF is requested. Assuming you have a content type to represent your PDF files, you could create a handler for that type and then call the tracking from that so that the tracking is called each time someone requests a PDF. Something like this:

[TemplateDescriptor(Inherited = true, TemplateTypeCategory = TemplateTypeCategories.HttpHandler, Default = true)]
public class PdfBlobHttpHandler : BlobHttpHandler, IRenderTemplate<MyPdfFileType>
    protected override Blob GetBlob(HttpContextBase httpContext)
        var trackingService = ServiceLocator.Current.GetInstance<ITrackingService>();
        //Add custom tracking here

        //Load and return the file data
        var routeHelper = ServiceLocator.Current.GetInstance<IContentRouteHelper>();
        var binaryStorable = routeHelper.Content as IBinaryStorable;
        return binaryStorable?.BinaryData;
Jan 07, 2021 21:22

You could of course also do client side tracking to some controller you manage on click and delay before letting the PDF navigation through. Similar to how you usually set it up in Google Tag Manager.

Edited, Jan 14, 2021 10:09

Great info.

Apr 16, 2021 10:48
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.