Skip to content
Public Ticket #19805

javascript snippet google analytics

Conversation thread

firosyd replied

Customer Reply

Thanks a lot!

PenciDesign Supporter replied

Staff Reply

Hi,

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

Regards,
PenciDesign.


firosyd replied

Customer Reply

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

PenciDesign Supporter replied

Staff Reply

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.


firosyd started the conversation

Conversation Start

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 

Want to join this conversation or access attachments? Sign in first.