How do I track who is accessing documents?

Posted by Community Admin on 04-Aug-2018 17:02

How do I track who is accessing documents?

All Replies

Posted by Community Admin on 05-Sep-2012 00:00

Hi there, 

Is there anyway to trap an event in Sitefinity when someone accessing a document ?
I need to track users who are accessing documents without using Google analytics.
Ex: When user download a pdf document.

Thanks
S

Posted by Community Admin on 10-Sep-2012 00:00

There are two events fired when a library item is being downloaded/viewed. You might try and subscribe to them in the global.asax file and from there check the file and the user. If the two match your conditions, you could save the condition in a db table for your use later on.

Events:
MediaContentDownloadingEvent
MediaContentDownloadedEvent

protected void Application_Start(object sender, EventArgs e)
    Bootstrapper.Initialized += new EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized);
    Bootstrapper.Initializing += new EventHandler<Telerik.Sitefinity.Data.ExecutingEventArgs>(Bootstrapper_Initializing);
 
protected void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
    Telerik.Sitefinity.Services.EventHub.Subscribe<Telerik.Sitefinity.Modules.Libraries.Web.Events.MediaContentDownloadedEvent>(new Telerik.Sitefinity.Services.Events.SitefinityEventHandler<Telerik.Sitefinity.Modules.Libraries.Web.Events.MediaContentDownloadedEvent>(this.MediaDownloaded));
 
private void MediaDownloaded(Telerik.Sitefinity.Modules.Libraries.Web.Events.MediaContentDownloadedEvent mediaEvent)
    throw new NotImplementedException();

From here you can get the properties of the media item and it even has a property called UserId which is set to the current logged in user id if they are logged in or an empty guid value.

Hope this helps.

Posted by Community Admin on 11-Sep-2012 00:00

I had to produce a report of which user has accessed what document and when. Because my requirements were a bit more involved, I did it through a UserControl droped on a page. It had no HTML so it was invisable, but the code would get executed behind the scenes when the page would load. Not nice but it did teh trick.

Posted by Community Admin on 13-Feb-2013 00:00

What Sitefinity version this valid for? 4.2 ?

This thread is closed