Send events to Google Analytics from inline form

SOLVE
Highlighted
Occasional Contributor

Is there a way to send events to Google Analytics after submission of an inline form on HubSpot?

On an external page, using the Javascript-snippet, there is the possibility to run whatever javascript you need, but when adding a form on the HubSpot platform, I see no option to send events or add custom code anywhere. Am I missing something or is this not possible?

Reply
0 Upvotes
2 Accepted solutions

Accepted Solutions
Community Manager

Hi @johdah,

 

Have you seen this resource? Let me know if that resolves the issue.

 

Thanks,
Jenny


Did my post help answer your query? Help the Community by marking it as a solution
Occasional Contributor

No I hadn't. Thanks for pointing me in the right direction!

For anyone else reading this, I'm posting the correct (in my case) answer here.
You can use the hsvalidatedsubmit event that fires after the form is validated.

 

In my case, I did this:

  $('body').on('hsvalidatedsubmit', '.hs-form', function (e) {
    ga('send', {
      hitType: 'X',
      eventCategory: 'Y',
      eventAction: 'Z',
    });
  });
  

 

Reply
0 Upvotes
2 Replies
Community Manager

Hi @johdah,

 

Have you seen this resource? Let me know if that resolves the issue.

 

Thanks,
Jenny


Did my post help answer your query? Help the Community by marking it as a solution
Occasional Contributor

No I hadn't. Thanks for pointing me in the right direction!

For anyone else reading this, I'm posting the correct (in my case) answer here.
You can use the hsvalidatedsubmit event that fires after the form is validated.

 

In my case, I did this:

  $('body').on('hsvalidatedsubmit', '.hs-form', function (e) {
    ga('send', {
      hitType: 'X',
      eventCategory: 'Y',
      eventAction: 'Z',
    });
  });
  

 

Reply
0 Upvotes