How to create on-click events for google analytics with javascript

I’m using generate press theme and elementor in wordpress and now we need to create on-click events for the menu and the buttons, see: eliv.com.tw/volunteerwithus. Since I can’t really use the html way to do it, I will need to use javascript. I’ve tried it like this:

<script>
     (function($){
         $( "#landingpage3-button1" ).click(function() {
             ga('send','event','phone call','header');
         });
     })(jQuery);
</script>`

However this doesn’t seem to work…

Any ideas how to fix this?

Best regards,

Florian

PS: I don’t really know javascript and got this code from someone else…

Read more here: How to create on-click events for google analytics with javascript

Leave a Reply

Your email address will not be published. Required fields are marked *