Simplest way to count a PDF hits/downloads?
I have a PDF on my site and simply want to know how many people have opened (downloaded) it.
I have it in a documents library, and the page uses the Download List widget to display it on the page. Thanks!
Hello
You can use the IMediaContentDownloadedEvent:
http://docs.sitefinity.com/for-developers-libraries-events#imediacontentdownloadedevent
You can use the ViewsCount property to keep the values.
Regards,
Nikola Zagorchev
Telerik
If you aren't comfortable with server side you could use google analytics to trigger an event when the users clicks the download button.
Hello all,
You can also use a custom field to save the views count, as well. Another option is using analytics as suggested. You can also vote for this feature request:
http://feedback.telerik.com/Project/153/Feedback/Details/99964-views-count-is-not-increasing-with-viewing-the-content-item-on-the-public-site
Regards,
Nikola Zagorchev
Telerik
Thank you. I am definitely on the content side and don't know much about the server side. I know how to tag a link via Google analytics (see below) , but in the Sitefinity download widget where my documents are, there is no html that I can change. In other words, I don't know where I would place my code.
... onClick="_gaq.push(['_trackPageview' ... etc
Hello
Which exact widget and widget template you are using? Is it possible to set the click using jQuery on document ready? You can include the javascript in the template.
Regards,
Nikola Zagorchev
Telerik
I am using the Download List Widget.
Widget is "List of Documents for Direct Download" I don't know about jQuery, but if it's possible and with some guidance, I can try. Then I would just include some javascript code in the existing template I'm using?? thank you
Hi Tom,
You can edit the "List of documents for direct download" template and set the following javascript at the bottom:
<script>
(
function
($)
$(document).ready(
function
()
$(
'.sfdownloadFile'
).on(
'click'
,
'a'
,
function
()
alert(
'clicked'
)
)
);
)(jQuery);
</script>
<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" TagPrefix="sf" %>
<
sf:ResourceLinks
ID
=
"ResourceLinks"
runat
=
"server"
>
<
sf:ResourceFile
JavaScriptLibrary
=
"JQuery"
></
sf:ResourceFile
>
</
sf:ResourceLinks
>