<?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: Post submission callback on an embedded form in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Post-submission-callback-on-an-embedded-form/m-p/239416#M18312</link>
    <description>&lt;P&gt;Hi Conor,&lt;/P&gt;
&lt;P&gt;Thanks for the reply. The documentation says the following for the onFormSubmit callback:&lt;/P&gt;
&lt;P&gt;"Callback that executes after form is validated, just before the data is actually sent."&lt;/P&gt;
&lt;P&gt;Emphasis on the &lt;EM&gt;before&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;I'm after a callback or hook for &lt;EM&gt;after&lt;/EM&gt; the data has been submitted.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Dan&lt;/P&gt;</description>
    <pubDate>Tue, 09 Oct 2018 15:47:59 GMT</pubDate>
    <dc:creator>dbaggs</dc:creator>
    <dc:date>2018-10-09T15:47:59Z</dc:date>
    <item>
      <title>Post submission callback on an embedded form</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Post-submission-callback-on-an-embedded-form/m-p/239414#M18310</link>
      <description>&lt;P&gt;Hi, I am embedded forms into our CMS hosted pages via the JS snippet provided and I'd like to perform some actions upon a successful or unsuccessful submission.&lt;/P&gt;
&lt;P&gt;Based on what I see here: &lt;A href="https://developers.hubspot.com/docs/methods/forms/advanced_form_options" rel="nofollow noopener"&gt;https://developers.hubspot.com/docs/methods/forms/advanced_form_options&lt;/A&gt;, there is no such callback. Is there anything I can hook into for this?&lt;/P&gt;
&lt;P&gt;For fuller context, I'd like to promote the success/error message into a notification banner that we utilise for UX consistency.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Dan&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2018 07:40:58 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Post-submission-callback-on-an-embedded-form/m-p/239414#M18310</guid>
      <dc:creator>dbaggs</dc:creator>
      <dc:date>2018-10-09T07:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: Post submission callback on an embedded form</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Post-submission-callback-on-an-embedded-form/m-p/239415#M18311</link>
      <description>&lt;P&gt;Hi &lt;A class="mention" href="https://community.hubspot.com/u/dbaggs"&gt;@dbaggs&lt;/A&gt;, you should be able to use the &lt;CODE&gt;onFormSubmit&lt;/CODE&gt; callback for post submission actions. You can also use &lt;CODE&gt;errorMessageClass&lt;/CODE&gt; to style your error messages accordingly, and you should be able to add markup to the &lt;CODE&gt;inlineMessage&lt;/CODE&gt; section, thereby allowing yourself the ability to add a class to a success message and subsequently styling that with CSS. What you're looking to do should certainly be possible as long as you are on a paid Basic, Professional, or Enterprise Marketing subscription.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2018 15:31:34 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Post-submission-callback-on-an-embedded-form/m-p/239415#M18311</guid>
      <dc:creator>cbarley</dc:creator>
      <dc:date>2018-10-09T15:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: Post submission callback on an embedded form</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Post-submission-callback-on-an-embedded-form/m-p/239416#M18312</link>
      <description>&lt;P&gt;Hi Conor,&lt;/P&gt;
&lt;P&gt;Thanks for the reply. The documentation says the following for the onFormSubmit callback:&lt;/P&gt;
&lt;P&gt;"Callback that executes after form is validated, just before the data is actually sent."&lt;/P&gt;
&lt;P&gt;Emphasis on the &lt;EM&gt;before&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;I'm after a callback or hook for &lt;EM&gt;after&lt;/EM&gt; the data has been submitted.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Dan&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2018 15:47:59 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Post-submission-callback-on-an-embedded-form/m-p/239416#M18312</guid>
      <dc:creator>dbaggs</dc:creator>
      <dc:date>2018-10-09T15:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: Post submission callback on an embedded form</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Post-submission-callback-on-an-embedded-form/m-p/239417#M18313</link>
      <description>&lt;P&gt;Hi &lt;A class="mention" href="https://community.hubspot.com/u/dbaggs"&gt;@dbaggs&lt;/A&gt;, have you explored the other options I mentioned? You can also use &lt;EM&gt;cssRequired&lt;/EM&gt; , which would be a string specific to validation error messages. If you're just looking to style the error and success messages, you should be able to do that with all of the properties defined in the advanced forms options page (&lt;A href="https://developers.hubspot.com/docs/methods/forms/advanced_form_options"&gt;https://developers.hubspot.com/docs/methods/forms/advanced_form_options&lt;/A&gt;). You can always style the inline messages with pure css from your stylesheet so there shouldn't be anything blocking you here unless you're not on Marketing Basic, Pro or Enterprise.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2018 15:53:58 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Post-submission-callback-on-an-embedded-form/m-p/239417#M18313</guid>
      <dc:creator>cbarley</dc:creator>
      <dc:date>2018-10-09T15:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: Post submission callback on an embedded form</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Post-submission-callback-on-an-embedded-form/m-p/239418#M18314</link>
      <description>&lt;P&gt;Thanks again Conor but that doesn't meet my needs.&lt;/P&gt;
&lt;P&gt;There are actually a couple of things I'd ideally like to do, which are JavaScript based. To be more concrete, you can imagine the notification banner I mentioned to be a JavaScript module we use that styles the notification in a way that means it is fixed to the top of the window and also attaches behaviour in that the user can close the notification in an nice animated way.&lt;/P&gt;
&lt;P&gt;Yes, you could replicate those styles to style the inner messages of the form but the attachment of behaviour to close the message would still need to be done.&lt;/P&gt;
&lt;P&gt;I'd rather not have to replicate and shoe-horn the styles to look the same but rather just hide the messages and be informed through a callback as to when I can read that message and delegate showing it via our existing module.&lt;/P&gt;
&lt;P&gt;Additionally, upon success of the form submission, I'd like to send a custom event to Google Analytics to track that asynchronous goal - again, to keep consistency with our existing UX (i.e. we don't want to redirect visitors to another page)&lt;/P&gt;
&lt;P&gt;Any pointers gratefully received.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Dan&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2018 16:19:48 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Post-submission-callback-on-an-embedded-form/m-p/239418#M18314</guid>
      <dc:creator>dbaggs</dc:creator>
      <dc:date>2018-10-09T16:19:48Z</dc:date>
    </item>
    <item>
      <title>Re: Post submission callback on an embedded form</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Post-submission-callback-on-an-embedded-form/m-p/239419#M18315</link>
      <description>&lt;P&gt;Do you think that I should be reading the documentation differently in that as the onFormSubmit fires &lt;EM&gt;after&lt;/EM&gt; the validation but before the actual sending, that I can assume that the data sending would be successful and therefore this is as good as a success case?&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 05:46:36 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Post-submission-callback-on-an-embedded-form/m-p/239419#M18315</guid>
      <dc:creator>dbaggs</dc:creator>
      <dc:date>2018-10-10T05:46:36Z</dc:date>
    </item>
    <item>
      <title>Re: Post submission callback on an embedded form</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Post-submission-callback-on-an-embedded-form/m-p/239420#M18316</link>
      <description>&lt;P&gt;Hey &lt;A class="mention" href="https://community.hubspot.com/u/dbaggs"&gt;@dbaggs&lt;/A&gt;, you're thinking about this in the right manner. The &lt;CODE&gt;onFormSubmit&lt;/CODE&gt; callback fires before the data is actually sent.&lt;/P&gt;
&lt;P&gt;Thank you for explaining your use case for this. In the end, you may use absolute positioning and some custom CSS/JS to move the inline message and error messages above the fold to a banner. A better option may be to create a custom HTML form so that you have full control over the form itself along with the banner messaging, then use our &lt;A href="https://developers.hubspot.com/docs/methods/forms/submit_form_ajax"&gt;Ajax submit data to a form endpoint&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;For the Google Analytics event, you may want to check out this previous post:&lt;/P&gt;
&lt;ASIDE class="quote quote-modified" data-post="1" data-topic="5793"&gt;
  &lt;DIV class="title"&gt;
    &lt;DIV class="quote-controls"&gt;&lt;/DIV&gt;
    &lt;IMG alt="" width="20" height="20" src="https://avatars.discourse.org/v2/letter/a/f17d59/40.png" class="avatar" /&gt;
    &lt;A href="https://integrate.hubspot.com/t/trigger-google-analytics-event-with-form-submission/5793"&gt;Trigger Google Analytics Event with Form Submission&lt;/A&gt; &lt;A class="badge-wrapper  bullet" href="https://community.hubspot.com/c/forms"&gt;&lt;SPAN class="badge-category-bg" style="background-color: #0E76BD;"&gt;&lt;/SPAN&gt;&lt;SPAN style="" data-drop-close="true" class="badge-category clear-badge" title="Questions about the Forms API, including submitting data to forms and customizing the form embed code."&gt;Forms&lt;/SPAN&gt;&lt;/A&gt;
  &lt;/DIV&gt;
  &lt;BLOCKQUOTE&gt;
    I read this article, which shows you how to add Google Analytics event tracking to a HubSpot form submission: 


I applied this to one of my embedded HubSpot forms, but it doesn’t seem to be tracking the event in Google Analytics. I am not using Google Tag Manager. 
Here is the code I used: 
hbspt.forms.create({ 
css: ‘’, 
portalId: ‘XXXXXXX’, 
formId: ‘XXXXXXX-XXX-XXX-XXXXXXX’, 
onFormSubmit: function($form) { 
"_gaq.push([’_trackEvent’, ‘Contact’, ‘contact_us_form’, ‘Main_Contact_Us’, false]);…
  &lt;/BLOCKQUOTE&gt;
&lt;/ASIDE&gt;</description>
      <pubDate>Thu, 11 Oct 2018 16:00:04 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Post-submission-callback-on-an-embedded-form/m-p/239420#M18316</guid>
      <dc:creator>cbarley</dc:creator>
      <dc:date>2018-10-11T16:00:04Z</dc:date>
    </item>
  </channel>
</rss>

