Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > Does Web Analytics track document-bound files? View modes: 
User avatar
Member
Member
seanbun-gmail - 5/13/2009 11:10:47 PM
   
Does Web Analytics track document-bound files?
Hi,

According to the documentation, all file downloads would be tracked by Web Analytics as long as "getfile.aspx" is triggered.

Developer Guide
File downloads - this report summarizes the number of files downloaded by the web site visitors and the most downloaded files. Please note that it tracks only the files managed by the CMS and served using the Kentico CMS scripts (GetFile.aspx).

I tried to upload a file as a document-bound file which stored as a part of a structured document (as a field in a document type). I downloaded the file via below 2 links, but it seems I could not find the file-download record in the log file (/app_data/cmsmodules/webanalytics/filedownloads_xxx.log)

1. Found this link by using the transformation of "GetFileURL(fieldname)".
http://localhost/getattachment/4cc21815-7ad1-430d-b195-42cd995ce51c/1587.aspx

2. Found this link on the top of the upload file textbox. it appears after you upload a file.
http://localhost/CMSPages/GetFile.aspx?guid=4cc21815-7ad1-430d-b195-42cd995ce51c&versionhistoryid=1323

After looking at the database, document-bound file would become an attachment and stored in the dbo.CMS_Attachment table. It is not part of theTree and does not have a NodeID. This makes me wondering if Web Analytics track the download activity. Since the methods in HitsInfoProvider Class require the NodeID.

Please advise.
Matt

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 5/28/2009 5:47:09 AM
   
RE:Does Web Analytics track document-bound files?
Hi,

Generally all of your suppositions are correct.
The best illustration how the file downloads are logged can be found directly in ~\CMSPages\GetFile.aspx.cs, e.g. lines like:

HitLogProvider.LogHit(HitLogProvider.FILE_DOWNLOADS, CurrentSiteName, file.FileNode.DocumentCulture, null, file.FileNode.NodeID);

As you can see, there is NodeID used. The GetFile script automatically gets the NodeID of the document whose attachment is being downloaded.
However you could also pass string argument (e.g. with alias path or the attachment filename) - it's the null argument in above LogHit method call example. Anyway, the file downloads report gets the displayed filename using the NodeID, so you would need to modify the report query(ies).
More info on custom reports and analytics can be found in DevGuide article.

The ../getattachment/.. in download URL is rewritten and GetFile.aspx handles the request. However, you probably miss one (quite important) information - the downloads are tracked only for CMS.File document type by default.
This can be seen in the condition(s) at lines #202 and 325 of GetFile.aspx.cs (version 4.0):

.. && (file.FileNode.NodeClassName.ToLower() == "cms.file")..

So to include your document's type file in file downloads, you could modify this condition(s) to include your doctype too:

.. && ((file.FileNode.NodeClassName.ToLower() == "cms.file") || (file.FileNode.NodeClassName.ToLower() == "cms.mydoctype"))


This will enable logging of downloads of the document attachments of your document type. Please note you will probably need to clear cache (preferably both application and browser's), the file download is logged only before it's in cache.

We willl try to upgrade our documentation and explicitly note the fact that only CMS.File is logged by default. Moreover, we'll try to bring KB article according to this topic - tracking custom documents attachments downloads.

Hope this will be helpful :)

We'll appreciate any comments, e.g. if you were succesful or not. Thanks.

Regards,
Zdenek C.

User avatar
Member
Member
seanbun-gmail - 5/28/2009 8:42:37 PM
   
RE:Does Web Analytics track document-bound files?
Hi Zdenek,

Thank you for your detailed explanation. It helps a lot and now I almost get the whole picture of the web analytics module.

My team also came up with a work-around to track document-bound files which may be worth to share with other KenticoCMS users. We worked on the CustomEventHandler and created a new node as a cms.file doc under the original document for any attachment after publishing (OnAfterPublish event). In the doctype form/transformation, we make sure people downloading from the new node instead of the path in the original document filed. Since the attachment now has its own id, we can easily get the download figure from the standard report.

This approach would avoid us to change any code on GetFile.aspx or any source code file and makes us easier to upgrade to the next version of KenticoCMS in the future.

Cheers,
matt
@seanbun

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 6/10/2009 3:10:22 PM
   
RE:Does Web Analytics track document-bound files?
Hi Matt,

thank you for sharing this information.
Although your way uses duplicate data, upgrade process should be really easier here.

Regards,
ZdenekC