Google Analytics Event Tracking

Hello,

I have an issue with Google Analytics events tracking, I’ve implemented the code, but still, there are no events in Analytics.
Implemented code:

<button onclick="ga('send', {
hitType: 'event',
eventCategory: 'demoForm',
eventAction: 'submit',
});" type="submit">SUBMIT</button>

How can I fix it?

Thank you in advance

Are you including the global site tag in the email? Without that your link can’t do anything.

Yes, on the website global site tag is using. To ensure I’ve reinstalled it, but still events not working.
Why you said global site tag in the email? Is there something need to be implemented additionally?

To stand a chance of your code working you need to include the global site tag in your email. Try adding the code to your email but in general JS inside emails is not widely supported.

But why I need to use global site tag in email?

I use infusionsoft form on a website, and I need to track this form. It must be working without any emails, when someone submits the form the Event must be triggered.
But it’s not working after event code implementation into the form on the website.

Apologies I misunderstood your question. Without seeing more of your code its hard to tell whats going on, maybe the form is submitted before ga() has a chance to complete.

I would advise you to debug test something like the following:

<script type="text/javascript">
function testFunction(){
  console.log('Entry');
  ga('send', {
hitType: 'event',
eventCategory: 'demoForm',
eventAction: 'submit',
});
  console.log('Exit');
  return false;
}
</script>

<button onclick="testFunction()" type="submit">SUBMIT</button>

Either way its not best practice to use onclick, you are better off using the likes of jQuery’s .on().

Unfortunately this example isn’t working.

Could you give jQuery example code?

What can you see in the console (Ctrl+Shift+K in Firefox)? If that isn’t displaying anything then jQuery isn’t going to help.

Hi alex did you solve it? I am having the same issue with google tags for tracking ads!

@Lucas_Finanzas I’ve trying to figure out how to implement Enhanced Conversions that are new in Google Ads. It needs to send name, email, phone, etc back to Google to help with cookieless tracking in the future (like the Facebook Conversions API). Have you figured out how to do that with Keap webforms? Previously, my conversion “event” had been a pageview on the thank-you page.