Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Tracking - Media library PDF Download View modes: 
User avatar
Certified Developer v7
Certified  Developer v7
Gitesh - 1/30/2013 8:01:52 PM
   
Tracking - Media library PDF Download
Hi Guys,

I can see that kentico web analytics is not tracking media libraries download. (Let me know if kentico already has got that feature)

We are using permamnet Url's for media libraries.
I have got few PDF's which I want to track when someone downloads. Below is an example of my pdf link:
/getmedia/dcc6591f-a2a0-4dee-b53f-b9c29c1f8be7/cardiology-research-review-issue-41.pdf.aspx?ext=.pdf

I have tried keeping my Analytics code in ~/CMSPages/GetMediaFile.aspx, but it didn't work (Code below):
<%@ Page Language="C#" AutoEventWireup="true" Inherits="CMSPages_GetMediaFile" CodeFile="GetMediaFile.aspx.cs" %>

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-*******-1']);
_gaq.push(['_trackPageview']);

(function () {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

Any other ideas for tracking Media Library PDF downloads?

Thanks
Gitesh Shah

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 1/31/2013 1:43:19 AM
   
RE:Tracking - Media library PDF Download
I asked about this feature back in v4 and v5 and it wasn't available. Not sure if it is now, but guessing not yet.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 2/10/2013 5:16:08 AM
   
RE:Tracking - Media library PDF Download
Hi,

Have you tried the approach mentioned in this forum thread?

Also, you can add custom logging as described in the documentation.

Best regards,
Juraj Ondrus

User avatar
Certified Developer v7
Certified  Developer v7
Gitesh - 4/19/2013 12:30:26 AM
   
RE:Tracking - Media library PDF Download
HI Juarj,

I have added my code in GetMediaFile.aspx.cs as below, I want only the pdf to be tracked:



protected void SendFile(CMSOutputMediaFile file)
{
// Clear response.
CookieHelper.ClearResponseCookies();
Response.Clear();

// Set the revalidation
SetRevalidation();

// Send the file
if (file != null)
{
if ((file.FileName != null) || (file.FileName != ""))
{
if (file.FileExtension.Contains("pdf"))
{
if (AnalyticsHelper.AnalyticsEnabled(CMSContext.CurrentSiteName))
{
HitLogProvider.LogHit("PDFDownloadTracker", CMSContext.CurrentSiteName, null, file.FileName, 0);
}

}
}



But for some reason instead of recording 1 hit , web analytics is recording random hits.

Could you please check if there is amistake in the above code or am I adding at the wrong place?

Thanks
Gitesh Shah

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 4/23/2013 7:24:18 PM
   
RE:Tracking - Media library PDF Download
Hi,

I do not see any problem in the code - I would run it in the debug mode and try accessing the file or files multiple times to see if the code is hit correctly every time.

Best regards,
Juraj Ondrus