APIs & Integrations

THirose
Participant | Partner
Participant | Partner

Non-HubSpot forms are not captured when they are submitted via Ajax.

Hello,

 

Our drupal website has a non-Hubspot form that sends form data with Ajax. Other non-HubSpot forms without Ajax are captured successfully by the HubSpot tracking code but the Ajax one is not. Is there any way to have the HubSpot code detect/capture the AJAX form submission and send the form data to our Hubspot account? Our intention here is not to write custom codes to send form data with Ajax using a POST request, rather to have all the non-HubSpot forms, including ajax and non-ajax ones, auto-captured upon submission by the HubSpot code.

 

Our website system environment:

  • HubSpot tracking code is integrated into the website with a google tag manager (by drupal GTM module).
  • HubSpot cookie compliance banner is enabled on the website.
  • Powered on Drupal 8. The ajax form is built with drupal webform module with an Ajax option enabled. If I disable the ajax, it works. But when I enable it again, doesn't work.

I looked at this knowledge-base page (https://knowledge.hubspot.com/forms/use-non-hubspot-forms) and tried everything I can, but still cannot get it working.

 

Thank you

4 Replies 4
ZincoSS
Member

Non-HubSpot forms are not captured when they are submitted via Ajax.

Please be aware that there is a known issue with Drupal where non-Hubspot forms are not being collected by HubSpot.

In Drupal webforms, there is an attribute called 'data-drupal-form-fields.' Strangely, when this attribute is present, the form does not submit data to HubSpot, and it results in the error message "Cannot find a matching submit button for the Drupal form."

To test this, you can place the following HTML on a page along with the HubSpot tracking code. It's important to note that this HTML form does not require Drupal CMS, Drupal Forms, or any other specific code:

<form data-drupal-form-fields="myfield">
    <input type="text" name="firstname" required>
    <input type="text" name="lastname" required>
    <input type="email" name="email" required>
    <input type="submit" value="submit">
</form>

Unfortunately, I have been unable to persuade HubSpot to address this issue, and their recommendation is to use the contributed Drupal Module, which can be found at this link: https://www.drupal.org/project/hubspot.

0 Upvotes
mtaggarts-5
Participant

Non-HubSpot forms are not captured when they are submitted via Ajax.

I am building a Drupal site (with an Opigno distribution) and I am running across a very similar issue.I added the drupal module HubSpot, and added my HubSpot Portal ID, and my Private App’s Client ID, Client Secret, and Scope. Enabled tracking code, and debugging. 

It just worked! It was tracking all of the form submissions from the native drupal (or non-hubspot forms): #user-pass, #user-form, #user-login-form, #user-register-form. (*As a side note I also see that it is tracking admin related submissions on my Drupal site like: #smtp-admin-settings)

My Private App is a little older, and didn’t have a Redirect URLs as this wasn’t a requirement when the app was built. I ended up adding some Redirect URLs and additionally pushed up some new code and Drupal modules to my site, and this day is when some of the forms stopped logging user submissions.

It started with: #user-register-form. But now I won’t find submissions from: #user-pass, #user-login-form, and #user-register-form. 
Initially I thought it was the code.

Using Pantheon I restored the database, code, files, and flushed all caches to a version of the website when the logging correctly worked. This still doesn’t log the form submissions in Hubspot. 
I created a basic version of the same website. With just the bare bones, and just adding the HubSpot module. Configured the Scope to the exact same as the live site. Same exact issue. 

And just to be clear: #user-login-form still is creating contacts in Hubspot, and adds all of the relevant information to the contact.

What do you think I should do to try and get these form submissions (#user-pass, #user-login-form, and #user-register-form) being logged into hubspot again? Is it the Private App Redirect Url's?

0 Upvotes
THirose
Participant | Partner
Participant | Partner

Non-HubSpot forms are not captured when they are submitted via Ajax.

Thank you for your reply, Himanshu!

 

I tried point 8 but still not working. I am thinking that Ajax in this case is what the point 3 is saying.

 

I'd like to know what the custom JS would be to have the HubSpot JavaScript code detect and capture an ajax non-HubSpot form submission. 

 

Regards,

Takaya

himanshurauthan
Thought Leader | Elite Partner
Thought Leader | Elite Partner

Non-HubSpot forms are not captured when they are submitted via Ajax.

Hi @THirose,

 

As mentioned here, in your case, point 3 and point 8 seem to be closely related and if that's the case then they won't be tracked without using the custom JS. 

 

image_2021_02_18T08_05_24_860Z.png

 

 

I guess this might help you.

 

Best Regards,

Digital Marketing & Inbound Expert In Growth Hacking Technology