Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #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

    #1105612

    Hey 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,
    Ismael

    #1106365

    Attached the login.

    On the Main Page i want to track 4 different events
    1.) Whatsapp Click
    2.) Facebook Click
    3.) Phone Click
    4.) Mail Click

    I also want to track the social media icons.

    Thanks!

    #1106561

    Hi,

    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,
    Ismael

    #1106591

    Hi,

    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

    #1106966

    Hi ronaldalexander,

    Does this solve your issue or do you need more help?

    Best regards,
    Victoria

    #1106970

    Hi,

    no! Its not working and i need help to get this done.

    Thanks!

    #1107361

    Hi,

    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,
    Ismael

    #1107685

    Thank you, but that doesn’t solve my problem regarding the 4 Icons on the Main Page (WhatsApp, Facebook Messenger, e.g.)

    Thanks!

    #1108763

    Hi,

    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,
    Ismael

    #1108874

    H 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.

    #1108975

    Hi,

    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,
    Ismael

    #1109219

    Amazing, thank you!

    #1109703

    Hi,

    You’re welcome! Glad we could be of help. Please don’t hesitate to open a new thread if you need anything else.

    Have a nice day.

    Best regards,
    Ismael

Viewing 14 posts - 1 through 14 (of 14 total)
  • The topic ‘Event Tracking Social Media Links’ is closed to new replies.