I am facing jquery uncaught error while using google analytics code for pdf

93 views Asked by At

I am using google analytical code for track pdf click event. I am using this code

 <script type="text/javascript">
  jQuery(function($) {
   jQuery(‘a[href$=".pdf"]’).click(function(){
  var pdf=jQuery(this).attr(‘href’);
   ga(‘send’,’event’, ‘pdf’, ‘download’, pdf);
   });

   });
  </script> 

But I am facing Uncaught SyntaxError: Invalid or unexpected token on line

jQuery(‘a[href$=".pdf"]’).click(function(){

Can anyone help me for this.

      
    

1

There are 1 answers

0
AhmerMH On

The single quote() you are using looks like the problem in the code. I tried the same code with this single quote('), it's working fine. Try below-written code, it works fine.

jQuery('a[href$=".pdf"]').click(function(){

The error will keep coming up because, in all your code, these italic quotes are used. Maybe you need to change your keyboard settings.