Check form input against existing lead data for that user | Community
Skip to main content
New Participant
March 24, 2023
Question

Check form input against existing lead data for that user

  • March 24, 2023
  • 2 replies
  • 2956 views

Hi!

 

I have a page with content locked behind a login, and I need to cover a scenario where a user has signed up to access this page, but is not currently cookied as a known user. They'll be putting their email address into a form, which I'd like to compare against all leads in the database. If their email address is found in the database, I'd like to see if they are included in a specific list (which would have a yes or no value). If they are included in that list, they get access to the page content.

 

Here's the code I have currently - as you'll see, I'm having some trouble figuring out how to connect to the leads database. 

 

I need to...

1. Grab their inputted value of the email field in the form

2. Look for that email address in the leads database

3. If they're found in the database, I need to grab all of their lead info based on their email address

4. I need to check the value of a specific piece of that lead info

 

You'll see some stuff about auth codes in here - we may change that in the future, but I believe the main roadblock I'm facing currently is grabbing this info from the database.

 

Thank you so much!!

 

 

<script> MktoForms2.loadForm("[url]", "[instance]", 1195, function(form) { form.onSuccess(function(vals, originalThankYouURL) { var thankYouURL = "/insider-access/" + vals.authCode; var newFollowUpURL = thankYouURL; if ( **The lead data associated with this email address has a specific piece of access marked true** ) { location.href = newFollowUpURL; } else { alert("Sorry we couldn't find your information, please sign up" ); } return false; }); }); </script>

 

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

SanfordWhiteman
New Participant
March 25, 2023

There's one flaw in your plan: the use of a Static List. That will not be feasible. However, if you switch to a person field (Boolean to indicate membership or DateTime to indicate membership + added date) this is doable.

 

You do it using my Pre-Fill JS (search past posts for links), submitting a simple email form and polling the DTP every 100ms until it's filled with their info. We've set this up for a few preference centers.

 

If you do implement this, be aware that the person doesn't need to prove they can get email at the provided address.

lbeecherAuthor
New Participant
March 27, 2023

Thank you! I don't believe we have a static list - we are actually looking to check if a boolean field = true, based off their email address and auth code. We don't need to verify the email address itself as being real, just need to check it against the existing data for that address to see if we can grant them access.

Taking a look at the pre-fill code now!

Darshil_Shah1
Community Manager
March 27, 2023

@lbeecher, here's the link to Sandy’s prefill approach. As you have mentioned that a unknown person would need to input the email address in the form, and when they submit the form they would get the Munchkin session associated with their person record in Marketo and the DTP/DTO prefill script will only query data of the person associated with that session. The code in the onSuccess handler would only be executed when the form is submitted successfully, and you could load the data from prefill JS post that (if the prefill JS isn’t able to return data in case the Munchkin session doesn’t get immediately associated to a known person record in Marketo, then you could also follow Sandy’s approach of querying for data every 100 ms until you the prefill JS returns response.). You should ideally gate this content page behind a form with password so people can’t access data that isn’t their own. Apologies if I’m missing anything here. 

New Participant
March 24, 2023

could you make this a 2-step verification where they must click a link in an email from marketo to get to gated content?