Join the Soledad Facebook Users Group here
for Share, assistance, discussion, and Updates related to Soledad WordPress Theme.

If you can't create a new ticket - you can send us an email via our contact form and we will get back to you.

Okay
  Public Ticket #2969676
javascript snippet google analytics
Closed

Comments

  •  3
    firosyd started the conversation

    Hi there,

    I added a button elementor in Home in order to tracking it via Google Analytics.

    Is there a place to insert the javascript code like this?

    ga('send', { 
      hitType: 'event', 
      eventCategory: 'Button Agenda 2022', 
      eventAction: 'click'
    })

    If possible do you know if the elementor button elementor allow "onclick" attribute in order to tracking the clicks in button?

    Thanks 

  •  2,610
    PenciDesign replied

    Hi,

    1. You can add this code to Appearance → Customize → Logo & Header → General → Add Custom Code Inside <head> tag.

    2. Yes. Elementor already support the "onclick" event of the button, please read the document detail here: https://elementor.com/help/button-widget/

    Regards,
    PenciDesign.


  •  3
    firosyd replied

    Hi there,

    I've seen the support page for button elementor - https://elementor.com/help/button-widget/ 

    I think better use it rather than the code previous sent to use it in head as you explained me.

    Hovewer, the procedures to the button tracking aren't same from another way - via javascript code for Google Analytics as sent previous.

    Now there is the code for the button:

    document.addEventListener("DOMContentLoaded", function(event) {
    jQuery('#My_Button a').click(function(){
    // tracking code here
    // for example Facebook Pixel:
    fbq('track','AddToCart');
    });
    });

    In this code I need setting the tracking code GA then it's enough to set tracking code GA inside in place of code Facebook Pixel without comment code? 

    There it's said to insert that code above in HTML widget but would be between tag <script></script> isn't it?

    Thank you so much

    Regards

  •  2,610
    PenciDesign replied

    Hi,

    Yes. You need to enter the JS code between the <script>code</script> tags.

    Regards,
    PenciDesign.


  •  3
    firosyd replied

    Thanks a lot!