Google-Analytics code to monitor the amount of downloads

Asked

Viewed 67 times

0

I need to enter a google-Analytics code to monitor how many times a file (a video) has been downloaded. But as it is a sidebar link that is generated dynamically, I have no way to enter directly into the code.

onclick="ga('send', 'event', 'link','click', 'Download clicado');"

Can someone shed some light on how I can do this?

1 answer

0

Well, I had to generate a jquery code that picked up the element reference; then I just told him to apply the following function:

<script>
jQuery(document).ready(function ($) {
   jQuery('.portfolio-side .panel:eq(2) a:eq(2)').click(function(){
      ga('send', 'event', 'Download', 'click', jQuery(this).text()); 
   });
});
</script>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.