![Check out Enfold](https://kriesi.at/wp-content/themes/kriesi/images/banner-enfold.jpg)
Tagged: link, onclick, social media buttons
-
AuthorPosts
-
July 8, 2021 at 11:28 am #1309235
Hi,
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.
https://support.google.com/analytics/answer/1136920?hl=tr#zippy=%2Cbu-makalede-ele-al%C4%B1nan-konular
Google says that in this article, link should be like this.***a href=”http://www.example.com” onclick=”captureOutboundLink(‘http://www.example.com’); return false; ** example.com’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=’https://api.whatsapp.com/send?phone=90533*******&text=Merhaba%2C+size+siteniz+uzerinden+ulasiyorum.’ title=’WhatsApp’ rel=”noopener”><span class=’avia_hidden_link_text’>WhatsApp</span> ///Best Cenk
-
This topic was modified 3 years, 2 months ago by
cengolino.
July 11, 2021 at 11:51 pm #1309622Hey 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() { ?> <script> (function($){ 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;"); })(jQuery); </script> <?php } add_action('wp_footer', 'custom_captureOutboundLink');
Best regards,
Mike -
This topic was modified 3 years, 2 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.