Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #605228

    Hi,

    I would like to include google analytics event tracking to my button created from the theme. Is there a way to add the neccesary code to it?

    The link should be something like that:
    <a href="http://www.fa.si/video/4B_SPLGIM_promo.mp4" onClick=”ga(‘send’, ‘event’, ‘TSM Downloads’, ‘download’, ‘Aftermovie’);”>TEST</a>
    *The link is not real

    I hope I made my question clear as english is not my native language. Thank you for your help.

    • This topic was modified 8 years, 7 months ago by fotoasja. Reason: corrected the code
    #605274

    I also tried to put the code in the code box but it also does not work. Any advice?

    #605277

    Hey!

    Please turn on custom CSS field for ALB elements – http://kriesi.at/documentation/enfold/turn-on-custom-css-field-for-all-alb-elements/ and edit your button and give it a custom CSS class and then add following code to Functions.php file in Appearance > Editor

    
    function my_custom_attr(){
    ?>
     <script>
    jQuery(window).load(function(){
    jQuery('.your-custom-class a').attr('onClick','YOUR CODE GOES HERE');
    });
     </script>
    <?php
    }
    add_action('wp_footer', 'my_custom_attr');

    Best regards,
    Yigit

    #605299

    Thank you for a fast response. How about multiple buttons with different code? Do I add just another instance of the code you provided?

    #605308

    Hi!

    You can additional lines to the code as following

    function my_custom_attr(){
    ?>
     <script>
    jQuery(window).load(function(){
    jQuery('.your-custom-class a').attr('onClick','YOUR CODE GOES HERE');
    jQuery('.your-custom-class-two a').attr('onClick','YOUR CODE GOES HERE');
    });
     </script>
    <?php
    }
    add_action('wp_footer', 'my_custom_attr');

    Regards,
    Yigit

    #605378

    I just can’t get it to work. Is my code ok?

    function my_custom_attr(){
    ?>
     <script>
    jQuery(window).load(function(){
    jQuery('.video a').attr('onClick','ga(‘send’, ‘event’, ‘TSM downloads’, ‘download’, ‘promo’);');
    jQuery('.videor a').attr('onClick','ga(‘send’, ‘event’, ‘TSM Downloads’, ‘download’, ‘reportaza’);');
    });
     </script>
    <?php
    }
    add_action('wp_footer', 'my_custom_attr');
    

    Again, thank you for your help.

    #606212
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.