Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #729837

    Hi there,

    How can I add a Google Analytics event to the search icon to very simply track if people click on it?

    Thanks in advance,
    Will

    #729968

    Hey willhendy,

    Please add following code to functions.php file in Appearance > Editor

    function av_search_ga(){
    ?>
     <script>
    jQuery(window).load(function(){
    jQuery('#top #menu-item-search a').attr('onclick','YOUR CODE GOES HERE');
    });
     </script>
    <?php
    }
    add_action('wp_footer', 'av_search_ga');

    Best regards,
    Yigit

    #730021

    Thanks Yigit. Does YOUR CODE refer to the Google Analytics code e.g. UA-XXXX?

    #730026

    Hey!

    Yes, you should insert the code you would like to trigger on click in ‘YOUR CODE GOES HERE’ section :)

    Cheers!
    Yigit

    #730028

    Right. I’m afraid you’ll have to educate me… I’m not clear what code I should be triggering on click.

    #730306

    Hi,

    Please refer to this post – https://developers.google.com/analytics/devguides/collection/analyticsjs/events

    Best regards,
    Yigit

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