+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / How do I track who is accessing documents?

How do I track who is accessing documents?

4 posts, 0 answered
  1. Suranga
    Suranga avatar
    12 posts
    Registered:
    22 Mar 2010
    05 Sep 2012
    Link to this post
    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
  2. Richard Baugh
    Richard Baugh avatar
    201 posts
    Registered:
    22 Aug 2012
    10 Sep 2012
    Link to this post
    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.
  3. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    11 Sep 2012
    Link to this post
    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.
  4. Suranga
    Suranga avatar
    12 posts
    Registered:
    22 Mar 2010
    13 Feb 2013 in reply to Richard Baugh
    Link to this post

    What Sitefinity version this valid for? 4.2 ?

4 posts, 0 answered