<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to track form submission events in Javascript? in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/How-to-track-form-submission-events-in-Javascript/m-p/237467#M16363</link>
    <description>&lt;P&gt;Thanks &lt;A class="mention" href="https://community.hubspot.com/u/dadams"&gt;@dadams&lt;/A&gt;!&lt;/P&gt;
&lt;P&gt;That did the trick. For future visitors to this page, I had to make one small change to your example to get it to work for me. Here’s what I did:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;$('body').on('hsvalidatedsubmit', '.hs-form', function (e) {
  var form = $(e.target);    
  var email = form.find('[name=email]').val();
  // analytics code goes here
});&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 21 Nov 2016 20:48:25 GMT</pubDate>
    <dc:creator>JZee</dc:creator>
    <dc:date>2016-11-21T20:48:25Z</dc:date>
    <item>
      <title>How to track form submission events in Javascript?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-to-track-form-submission-events-in-Javascript/m-p/237465#M16361</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;I’m trying to integrate a 3rd party analytics tool into my HubSpot landing pages. Specifically, I need to call the &lt;A href="https://heapanalytics.com/docs/custom-api#identify" rel="nofollow noopener"&gt;Heap Analytics Identify&lt;/A&gt; call when a user submits a form on our landing page, and I need to send some of that form data (the email field) to Heap as part of the call. &lt;A href="http://Segment.io" rel="nofollow noopener"&gt;Segment.io&lt;/A&gt; and many other tracking tools work in the exact same way.&lt;/P&gt;
&lt;P&gt;I couldn’t find any instructions on how to do this in HubSpot’s documentation itself, but a quick Google search lead me to this blog post: &lt;A href="https://robsobers.com/tracking-form-submission-events" rel="nofollow noopener"&gt;https://robsobers.com/tracking-form-submission-events&lt;/A&gt;. The post explains my issue exactly, and the solution is exactly what I need! Unfortunately, however… it doesn’t work. The “hsvalidatedsubmit” event doesn’t seem to be getting fired.&lt;/P&gt;
&lt;P&gt;Can someone tell me what event I should listen for, and/or how to integrate a callback for custom tracking on the client-side?&lt;/P&gt;
&lt;P&gt;Thanks in advance!!!&lt;BR /&gt;
Joe&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2016 21:53:53 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-to-track-form-submission-events-in-Javascript/m-p/237465#M16361</guid>
      <dc:creator>JZee</dc:creator>
      <dc:date>2016-11-17T21:53:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to track form submission events in Javascript?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-to-track-form-submission-events-in-Javascript/m-p/237466#M16362</link>
      <description>&lt;P&gt;Hi &lt;A class="mention" href="https://community.hubspot.com/u/jzee"&gt;@JZee&lt;/A&gt; ,&lt;/P&gt;
&lt;P&gt;The &lt;CODE&gt;hsvalidatedsubmit&lt;/CODE&gt; event should still be firing, so you should still be listening for that event. My guess is that the &lt;CODE&gt;.on()&lt;/CODE&gt; handler isn’t getting attached to the form, since forms load asynchronously after the page loads. You’d need to attach the handler to an element that will be a parent element of the form, that would already be on the page when your code runs, then filter by the actual form class. If you’re using a form module on a HubSpot page, adding this to the footer of the page should work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;$('.hs_cos_wrapper_type_form').on('hsvalidatedsubmit', '.hs-form', function (e) {
    //analytics code goes here
});&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Nov 2016 22:46:48 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-to-track-form-submission-events-in-Javascript/m-p/237466#M16362</guid>
      <dc:creator>Dadams</dc:creator>
      <dc:date>2016-11-17T22:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to track form submission events in Javascript?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-to-track-form-submission-events-in-Javascript/m-p/237467#M16363</link>
      <description>&lt;P&gt;Thanks &lt;A class="mention" href="https://community.hubspot.com/u/dadams"&gt;@dadams&lt;/A&gt;!&lt;/P&gt;
&lt;P&gt;That did the trick. For future visitors to this page, I had to make one small change to your example to get it to work for me. Here’s what I did:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;$('body').on('hsvalidatedsubmit', '.hs-form', function (e) {
  var form = $(e.target);    
  var email = form.find('[name=email]').val();
  // analytics code goes here
});&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Nov 2016 20:48:25 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-to-track-form-submission-events-in-Javascript/m-p/237467#M16363</guid>
      <dc:creator>JZee</dc:creator>
      <dc:date>2016-11-21T20:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to track form submission events in Javascript?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-to-track-form-submission-events-in-Javascript/m-p/237468#M16364</link>
      <description>&lt;P&gt;Is there a recommended way of doing this for leadin and collected forms?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2017 21:23:30 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-to-track-form-submission-events-in-Javascript/m-p/237468#M16364</guid>
      <dc:creator>lukebussey</dc:creator>
      <dc:date>2017-02-24T21:23:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to track form submission events in Javascript?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-to-track-form-submission-events-in-Javascript/m-p/237469#M16365</link>
      <description>&lt;P&gt;From where we can put this code on landing page form? I want that submitted data in my server script so i can store in DB.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 15:14:50 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-to-track-form-submission-events-in-Javascript/m-p/237469#M16365</guid>
      <dc:creator>sanketwebinopol</dc:creator>
      <dc:date>2017-05-31T15:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to track form submission events in Javascript?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-to-track-form-submission-events-in-Javascript/m-p/741038#M60281</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to do the same but without using jQuery event but Vanilla javascript?&lt;/P&gt;&lt;P&gt;We don't use jQuery in our site and would prefer not to use it if possible just for this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;JM&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2023 07:39:58 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-to-track-form-submission-events-in-Javascript/m-p/741038#M60281</guid>
      <dc:creator>JM10</dc:creator>
      <dc:date>2023-01-13T07:39:58Z</dc:date>
    </item>
  </channel>
</rss>

