-
AuthorPosts
-
May 27, 2019 at 6:54 pm #1104571
Hi, i am using event tracking on my mailto links.
Code: (Email address hidden if logged out) “> (Email address hidden if logged out)
My Problem is when i want to use the event tracking on the social media links its not working. How can i implement this code without the tags?
Screenshot attached: https://imgur.com/8nN177L
Thanks
May 31, 2019 at 7:50 am #1105612Hey ronaldalexander,
Thank you for using Enfold.
Is this for a google analytics tracking? How did you implement it for the mailto links? You may need to add an onclick attribute to the social icon using javascript/jQuery.
Best regards,
IsmaelJune 2, 2019 at 2:55 pm #1106365Attached the login.
On the Main Page i want to track 4 different events
1.) Whatsapp Click
2.) Facebook Click
3.) Phone Click
4.) Mail ClickI also want to track the social media icons.
Thanks!
June 3, 2019 at 4:32 am #1106561Hi,
Is this for a google analytics tracking? How did you implement it for the mailto links?
How do you want to track it? Are you using google analytics?
Have you created custom event goals?
// https://support.google.com/analytics/answer/1032415
You may have to modify the includes > helper-social-media.php file directly or use Javascript.
Best regards,
IsmaelJune 3, 2019 at 7:48 am #1106591Hi,
yes i put my events in Google Analytics
1.) Whatsapp: onclick=”gtag(‘event’, ‘Click’, { ‘event_category’: ‘Whatsapp’ });
2.) Facebook: onclick=”gtag(‘event’, ‘Click’, { ‘event_category’: ‘Facebook’ });
3.) Phone: onclick=”gtag(‘event’, ‘Click’, { ‘event_category’: ‘Phone’ });
4.) Mail : onclick=”gtag(‘event’, ‘Click’, { ‘event_category’: ‘Email’ });Bests
June 4, 2019 at 10:18 am #1106966Hi ronaldalexander,
Does this solve your issue or do you need more help?
Best regards,
VictoriaJune 4, 2019 at 10:24 am #1106970Hi,
no! Its not working and i need help to get this done.
Thanks!
June 5, 2019 at 6:07 am #1107361Hi,
Sorry for the confusion.
You can try this script in the functions.php file to trigger the corresponding gtag function when one of the social icons is clicked.
add_action('wp_footer', 'ava_social_gtag'); function ava_social_gtag(){ ?> <script type="text/javascript"> (function($) { $('.social_bookmarks_facebook a').on('click', function() { gtag('event', 'Click', { 'event_category': 'Facebook' }) }); $('.social_bookmarks_mail a').on('click', function() { gtag('event', 'Click', { 'event_category': 'Mail' }) }); $('.social_bookmarks_tel a').on('click', function() { gtag('event', 'Click', { 'event_category': 'Telephone' }) }); })(jQuery); </script> <?php }
Best regards,
IsmaelJune 5, 2019 at 4:46 pm #1107685Thank you, but that doesn’t solve my problem regarding the 4 Icons on the Main Page (WhatsApp, Facebook Messenger, e.g.)
Thanks!
June 10, 2019 at 8:20 am #1108763Hi,
I didn’t know that you’re using custom icons. You need to assign or apply a custom css class attribute to those icons and use them in place of the selectors in the above function.
// https://kriesi.at/documentation/enfold/add-custom-css/#enable-custom-css-class-name-support
Thanks for the update.
Best regards,
IsmaelJune 10, 2019 at 8:07 pm #1108874H Ismael,
thanks for you reply!
Can you send me ready code since i am stuck getting this to work. The WhatsApp & Facebook Icon is one Element and the Phone and Email Icon is the second element. I don’t have 4 elements to use 4 different css classes. The Social Icons are now clear to me but not how to track the 4 different icons on the mail page separately.
Thanks for your help, appreciate that.
June 11, 2019 at 4:13 am #1108975Hi,
Thank you for the update.
We applied an additional custom css class to the icons and adjusted the script accordingly.
//------------------------------- // Social Media icons + tracking //------------------------------- add_action('wp_footer', 'ava_social_gtag'); function ava_social_gtag(){ ?> <script type="text/javascript"> (function($) { $('.cta-icons-kontakt-1 li:nth-child(1) a').on('click', function(e) { gtag('event', 'Click', { 'event_category': 'Whatsapp' }) }); $('.cta-icons-kontakt-1 li:nth-child(2) a').on('click', function(e) { gtag('event', 'Click', { 'event_category': 'Facebook' }) }); $('.cta-icons-kontakt-2 li:nth-child(1) a').on('click', function(e) { gtag('event', 'Click', { 'event_category': 'Phone' }) }); $('.cta-icons-kontakt-2 li:nth-child(2) a').on('click', function(e) { gtag('event', 'Click', { 'event_category': 'Email' }) }); })(jQuery); </script> <?php }
The icons executes the gtag function now when clicked. (see private field)
Best regards,
IsmaelJune 11, 2019 at 5:02 pm #1109219Amazing, thank you!
June 13, 2019 at 5:50 am #1109703 -
AuthorPosts
- The topic ‘Event Tracking Social Media Links’ is closed to new replies.