Solved

Issue with Legacy form redirecting on form submission

  • 6 October 2021
  • 10 replies
  • 256 views

Badge

I’m running into an issue where the the legacy form sometimes redirects to page with another form asking for the email, first name, and last name. But this only seems to happen sometimes. I’ve added the data attributes: data-ajax-submit, target, and novalidate. Thanks in advance for the help!

icon

Best answer by alex.hong 8 October 2021, 00:32

View original

10 replies

Badge

@jallain tagging you here if you have any ideas of what could be going on. Thanks again for all your help!

Userlevel 4
Badge +9

@arianavmac thanks for tagging me! Can you provide the code that you are currently using for the form so I can see if anything looks off? Or even a link to the page where the form is and I can see it in action there.

Userlevel 4
Badge +9

I did also find this topic which sounds relevant. May be worth looking at:

 

 

Badge

https://new-imaware.webflow.io/at-home-blood-test/vitamin-d 
If you click on “View Sample Report” the form should come up.
I’ve tried omitting data-ajax-submit as suggested in that link but no luck yet sadly

Userlevel 4
Badge +9

@arianavmac is your form making a POST request? You may want to also remove the GET method attribute and the URL action that it is opening.

Badge

@jallain I removed that, but then users don’t show up in klaviyo, would the right thing to do is keep the URL but it make it a POST request instead?

Userlevel 4
Badge +9

You should be making a POST request from the form. Here’s an article that you can use as reference if you haven’t seen it already: https://help.klaviyo.com/hc/en-us/articles/115005249548-How-to-Add-and-Customize-a-Legacy-Popup

 

For the “success” function, you can see it should be running after the POST request:

 

  • success: optional, function. Set a custom function to run on a successful AJAX post.

 

It looks like you have customized the code in some way so perhaps you want to fully control the form and where it sends data to instead of relying on Klaviyo’s code to do it for you?

Badge

Hm strange, when I do POST no users gets added to Klaviyo, when I do GET it does. I did GET because that’s what it says to do here: https://help.klaviyo.com/hc/en-us/articles/115005249588-How-to-Add-and-Customize-a-Legacy-Embedded-Signup-Form

Userlevel 4
Badge +9

@arianavmac hmm, it does mention an ajax post request in the article as well so perhaps that is incorrect? can you see the request being made in the network tab of your dev tools?

Userlevel 6
Badge +51

Hi @arianavmac!

Posting here to stay updated. Looks like @jallain is correct and is offering great assistance. I think for general steps if you haven’t tried yet:

Generally when a sign-up form redirects to a subscribe page, it's because there are two forms on the website with the same id. To remedy this issue, you'll need to update the id of one of the forms. Detailed steps are outlined below.

  1. Go to the page where the form(s) exist. Right click on the “email” field of the form and inspect the code.

  2. Confirm the form is a Klaviyo form and take notice to the Form ID and its corresponding JavaScript.

  3. If there is another form on the page with the same Form ID, the JS will break and cause the form to redirect to the Klaviyo Subscribe page. To prevent this, change the Form ID and Javascript for ONE of the forms to separate the two.

  4. With this now being separate of the other Klaviyo form, the form should submit as intended with no redirect.

Looking to see the updates as well!

Alex

Reply