Hi,
In short, you can create a webpart or control where you would use WebAnalytics API to log a hit and store current user information. This webpart can be placed into the master page template (or to the specific set of templates according your needs). The logged information would then be used in your
custom report.
Generally, when logging an event, saving of the user's name (login) is done by passing appropriate parameters on
CMS.WebAnalytics.HitLogProvider.LogHit method call. You will need to use your own name as
CodeName parameter (1st) and pass the
username/login/userID value as the
ObjectName parameter (4th one).
Please find the sample code below:
if (CMS.WebAnalytics.AnalyticsHelper.AnalyticsEnabled(CMSContext.CurrentSiteName))
{
CMS.WebAnalytics.HitLogProvider.LogHit("MembershipDocumentPageView", CMSContext.CurrentSiteName, CMSContext.CurrentUser.PreferredCultureCode, CMSContext.CurrentUser.UserName, CMSContext.CurrentDocument.DocumentId);
}
The string parameter
ObjectName is saved in the
Analytics_Statistics table in the
StatisticsObjectName column. This column is used for any string you want to log, it doesn't have any predefinied purpose. Some reports, as you can see in this table, use also the
StatisticsObjectID column, in your case this will be the ID of the requested document (file). After you change this, you'll also have to customize the report generated so it can be displayed. Please see the
custom reports article for details.
Some details about tracking downloads per user can be found in
this thread.
It would be possible to store the information in your custom webpart into custom table, however the WebAnalytics uses better & scalable method of capturing the data, so that it won't create such load to the DB, what would happen with higher traffic on the website.
Should you need any additional details, feel free to ask.
Regards,
Zdenek