Skip to main content

So I have published a signup form on a landing page on our website. We want to use this signup form to collect user data like first name, date of birth etc.

 

I don't want the customers to need to fill in their e-mailadress. It should be prefilled since we already know what the e-mailadress is. We will link to this page from a welcome e-mail, which will have the e-mailadress in the URL www.example.com/newsletter-data?email=xxx@xxx.nl

 

Now I have already built this part with JavaScript and I can see that the e-mailadress is added the the Klaviyo form from the URL. However after like 1 second it is removed again (I guess by Klaviyo itself). So you can see it being added and then with a flicker it dissapears again.

 

Does anybody know how I fix this? Or is there a different way to accomplish this? (withou Klaviyo custom hosted pages)

 

Thanks in advance!

Hi @meisterSybren!
 

This might be happening because Klaviyo has security measures in place to prevent malicious attacks on their platform by checking the source of the email being added to the form. When you add the email through a URL, Klaviyo might flag it as potentially harmful and remove it.

A solution to this issue would be to use Klaviyo's APIs to pre-populate the form with the email from the URL. Here's a basic example of how you could do this with JavaScript:

<script type="text/javascript">

  // get the email from the URL query string

  var email = getQueryStringValue('email');

  

  // if an email is present, pre-populate the email field

  if (email) {

    document.getElementById("klaviyo_field_0").value = email;

  }

  function getQueryStringValue(key) {

    return decodeURIComponent(window.location.search.replace(new RegExp("^(?:.*e&\\?]" + encodeURIComponent(key).replace(/e\.\+\*]/g, "\\$&") + "(?:\\=("^&]*))?)?.*$", "i"), "$1"));

  }

</script>

You would need to replace klaviyo_field_0 with the ID of the email field in your Klaviyo form.

 

But remember to stick to best practices when sending emails. Make it easy for your subscribers to unsubscribe or change their preferences. Also, be careful not to fall into the spam trap, which can lead to account blocking. 
 

I hope this helped, if you have any other questions, just let me know)


Reply