Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > User Analytics View modes: 
User avatar
Member
Member
Rich - 7/23/2012 9:25:26 AM
   
User Analytics
Hello,
Is it possible to generate an Analytics report in Kentico that shows which users have downloaded particular PDF documents?

If Kentico is not capable of logging this, are there any similar third-party tools?

Many thanks,
Rich

User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 7/23/2012 10:16:33 AM
   
RE:User Analytics
I have done this using google analytics and a little javascript.

Google analytics exposes some functions you can use to make it track certain things as a page view. Here is a snippet I used to attach an event listener to links that I've marked with the CSS class 'track' added to it.


(function(){
jQuery('a.track').each(function(){
var l = this;
jQuery(l).bind('click',function(){
_gaq.push(['_trackPageview', jQuery(this).attr('href')]);
});

});
})();


Modify it to suit your needs.

User avatar
Member
Member
Rich - 7/23/2012 10:23:57 AM
   
RE:User Analytics
Hi Jiveabillion, Thanks for your feedback.

I can see that this would track the page views at the given URL, and I have also used Google Event tracking on PDFs before, however this wouldn't show which Kentico user had clicked the link. I guess this functionality isn't available built in.

Thanks,
Rich

User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 7/23/2012 2:00:38 PM
   
RE:User Analytics
You could maybe append the current username as a querystring parameter to the href value in the javascript. You could export data from google analytics and write some code to parse it out.


I don't think it's built-in to Kentico, but I could be wrong.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 7/24/2012 1:44:57 AM
   
RE:User Analytics
Hi,

It is not built in - usually the wanted reports are about the number of downloaded files and not who downloaded it.

I agree with the above query string approach.
Also, you can edit the CMSPages/getfile.aspx.cs code to add to the URL the user name and store the value using custom code and then create a report.

Best regards,
Juraj Ondrus

User avatar
Member
Member
Gareth - 10/10/2013 12:36:06 PM
   
RE:User Analytics
Hello there,

I have just started using Google Analytics (GA) on our Kentico site and everything works well... except the event tracking. I've pretty much done all that there is to do but GA still isn't tracking the events. This is what I've placed in CMS Desk:

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-********-*']);
_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>
I think I also posted this on my master page and my two-column template.

and the links look like this:

<a href="/Documents/Practice-Support-Documents/Scope-of-Practice-ONLINE.aspx" onClick="_gaq.push(['_trackEvent', 'PolicyPractice', 'Click', 'Scope of Practice Document']);"> Scope of Practice for Licensed Practical Nurses</a>


I'm quite new to coding, so please bear with me.

Thank you

User avatar
Member
Member
kentico_sandroj - 10/11/2013 8:54:05 PM
   
RE:User Analytics
Hello,

In case anyone else is facing this issue, our suggestion was to replace the above referenced script with the following:

<script type="text/javascript">
function trackOutboundLink(link, category, action) {

try {
_gaq.push(['_trackEvent', category , action]);
} catch(err){}

setTimeout(function() {
document.location.href = link.href;
}, 100);
}
</script>