Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #1309235


    I use Enfold to built my website. I’m quiet happy but I need to track social media buttons on Google Analytics. I added some codes to functions.php but I need to change Social Media buttons to onclick link buttons.
    Google says that in this article, link should be like this.

    ***a href=”” onclick=”captureOutboundLink(‘’); return false; **’a göz atın***

    As you can see regular code as below has no onclick codes. How can I change this. Urgent HELP.

    <li class=’social_bookmarks_whatsapp av-social-link-whatsapp social_icon_2′>
    ///a target=”_blank” href=’*******&text=Merhaba%2C+size+siteniz+uzerinden+ulasiyorum.&#8217; title=’WhatsApp’ rel=”noopener”><span class=’avia_hidden_link_text’>WhatsApp</span> ///

    Best Cenk

    • This topic was modified 2 years, 9 months ago by cengolino.

    Hey cengolino,
    Thank you for your patience and for the link to your site and the code you wanted to add, I wrote this function that you can add to your functions.php but I would recommend using a Child Theme so that it won’t be lost in an update.

    function custom_captureOutboundLink() { ?>
        var getinstagram = $(".main_menu .social_bookmarks_instagram a").attr("href");
        var getwhatsapp = $(".main_menu .social_bookmarks_whatsapp a").attr("href");
        var getfacebook = $(".main_menu .social_bookmarks_facebook a").attr("href");
        $(".main_menu .social_bookmarks_instagram a").attr("onclick", "captureOutboundLink("+ getinstagram +"); return false;");
        $(".main_menu .social_bookmarks_whatsapp a").attr("onclick", "captureOutboundLink("+ getwhatsapp +"); return false;");
        $(".main_menu .social_bookmarks_facebook a").attr("onclick", "captureOutboundLink("+ getfacebook +"); return false;");
    add_action('wp_footer', 'custom_captureOutboundLink');

    Best regards,

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