Code google-analytics to monitor the number of downloads

0

I need to insert a google-analytics code to monitor how many times a file (a video) has been downloaded. But since it is a sidebar link that is generated dynamically, I can not insert direct into the code.

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

Can anyone give me a light on how I can do this?

    
asked by anonymous 01.09.2017 / 19:20

1 answer

0

Well, I had to generate a jquery code that took the reference of the element; 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>
    
01.09.2017 / 21:45