# Auth0 (Universal Login) and HubSpot Tracking Code (with Collected Forms)

**URL:** <https://community.hubspot.com/t/auth0-universal-login-and-hubspot-tracking-code-with-collected-forms/87589>\
**Category:** APIs & Integrations\
**Tags:** forms\
**Created:** [August 16, 2023, 7:57am UTC](https://community.hubspot.com/t/auth0-universal-login-and-hubspot-tracking-code-with-collected-forms/87589 "2023-08-16T07:57:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fs\_mb](https://avatars.discourse-cdn.com/v4/letter/f/0ea827/32.png) [@fs\_mb](https://community.hubspot.com/u/fs_mb)\
**Post date:** [August 16, 2023, 7:57am UTC](https://community.hubspot.com/t/auth0-universal-login-and-hubspot-tracking-code-with-collected-forms/87589/1 "2023-08-16T07:57:57Z")

</div>

Hey!

We are using Auth0 new universal login and HubSpot Tracking Code with form collection. Form collection does not work. HubSpot submit event tracking is binded successfully to Auth0 form, but the HTTP Post to [https://forms.hscollectedforms.net/collected-forms/submit/form](https://forms.hscollectedforms.net/collected-forms/submit/form) gets cancelled immediately when the Auth0 finishes the authentication.

Any suggestions? Thank you!

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [August 17, 2023, 11:25pm UTC](https://community.hubspot.com/t/auth0-universal-login-and-hubspot-tracking-code-with-collected-forms/87589/2 "2023-08-17T23:25:31Z")

</div>

Hey, [@fs\_mb](https://community.hubspot.com/t5/user/viewprofilepage/user-id/616294) 👋 Welcome to our community! I don’t have a solution for you. And I’d love to brainstorm with you a bit. Have you looked into utilizing `event.preventDefault()`?— [MDN Event: preventDefault() method](https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault).

- Try using `event.preventDefault()` to prevent the Auth0 form from submitting immediately
- Submit the HubSpot form using our API or manually trigger it using the form’s `submit` event
- Wait (listen) for the HubSpot form submission to complete
- Resume the Auth0 authentication

This is a rough outline that makes multiple assumptions. If you’ve already ruled this out or found a different path for success, please let our community know.

Have fun building! — Jaycee

---

<div class="post-metadata">

**Author:** ![fp\_mb](https://avatars.discourse-cdn.com/v4/letter/f/5f8ce5/32.png) [@fp\_mb](https://community.hubspot.com/u/fp_mb)\
**Post date:** [August 18, 2023, 7:58am UTC](https://community.hubspot.com/t/auth0-universal-login-and-hubspot-tracking-code-with-collected-forms/87589/3 "2023-08-18T07:58:54Z")

</div>

Hi Jaycee,

I am a colleague of [@fs\_mb](https://community.hubspot.com/t5/user/viewprofilepage/user-id/616294).

So we have a react SPA with a ( **non-hubspot** ) form (react-hook-form) that hooks onto onSubmit for validation. Once validation passes we call the Auth0-js login which triggers a browser redirect.

This redirect is what (sometimes) cancels the in-flight HubSpot form submission.

Your idea has merit but I don’t know how to wait for the HubSpot (non-hubspot) form submission to finish. The docs mention listening on the window.onmessage but that seems to me to be only for Hubspot forms in an iframe (i.e. not non-hubspot forms).

Could you clarify this for me please?

Thank you!
