SOLVED

If Known User Show Form - Conditional

Go to solution

If Known User Show Form - Conditional

Hello - So basically I am trying to use the 'If Known Visitor, Show: Custom HTML' form feature. What I am trying to do is show the form if the first name for a known user meets certain conditions. 

If the known user's:

//  First name contains punctuation marks OR

// First name is 'update'  OR
// First name has only one letter in it
then --> show the form
Otherwise if they are a known user and their first name doesn't meet any of those conditions, hide the form. 
Is this possible to do this based on those conditions?
1 ACCEPTED SOLUTION

Accepted Solutions

Re: If Known User Show Form - Conditional

You'd put this CSS stylesheet* in your <head>:

<style>
.mktoForm
{
position: absolute;
visibility: hidden;
}
.mktoForm[data-dynamic-displayable="true"] {
position: static;
visibility: visible;
}
</style> ‍‍‍‍‍‍‍‍‍‍

Then this JS right before the closing </body> tag:

<script>
(function(){
var mktoFields = {
FirstName : "{{Lead.First Name}}"
}

if( mktoFields.FirstName == "Amelia" ){
MktoForms2.whenReady(function(form){
var formEl = form.getFormElem()[0];
formEl.setAttribute("data-dynamic-displayable",true);
});
}
})();‍‍‍‍‍‍‍‍‍‍‍‍
</script>‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Substituting your actual conditions for == "Amelia".

I need to note that your notion of "punctuation marks" isn't specific enough. There are lots of marks (Unicode Punctuation, * character categories) that are found in First Names. In Latin-1 alone, periods, parentheses, hyphens, apostrophes, and quotation marks are part of given names as entered on forms. Sure, there are hundreds of other punctuation marks that are not typically part of given names, but you have to ask yourself whether it's worth the penalty of telling people Your name is not your name in order to catch a few outliers. We err on the side of trust; I'm not going to tell someone who enters "Jane #2" that they can't buy a product, while some spam lead who happens to use the first name "Joe" is good. .

Also note that South Indian given names (assigned initials) frequently are only one letter.  It would be wrong to tell someone their effective first name is not "S", because that is their name, and it's not supposed to be spelled out. You'd just be alienating millions of potential leads.

* If anybody is curious about why I didn't use display:none; it's because the forms library must calculate the rendered width accurately.

Do this whenever you want to show a form conditionally (as opposed to load a form conditionally).

Here the named mktoForm element is always loading; otherwise you'd have to switch to  the embed, which is wrong on Marketo LPs.

View solution in original post

5 REPLIES 5

Re: If Known User Show Form - Conditional

Not out-of-the-box but certainly with a some helper JS.  Is this on a Marketo LP?

Re: If Known User Show Form - Conditional

Yes, the form is on a Marketo Landing Page. Do you know what helper JS should be used?

Re: If Known User Show Form - Conditional

You'd put this CSS stylesheet* in your <head>:

<style>
.mktoForm
{
position: absolute;
visibility: hidden;
}
.mktoForm[data-dynamic-displayable="true"] {
position: static;
visibility: visible;
}
</style> ‍‍‍‍‍‍‍‍‍‍

Then this JS right before the closing </body> tag:

<script>
(function(){
var mktoFields = {
FirstName : "{{Lead.First Name}}"
}

if( mktoFields.FirstName == "Amelia" ){
MktoForms2.whenReady(function(form){
var formEl = form.getFormElem()[0];
formEl.setAttribute("data-dynamic-displayable",true);
});
}
})();‍‍‍‍‍‍‍‍‍‍‍‍
</script>‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Substituting your actual conditions for == "Amelia".

I need to note that your notion of "punctuation marks" isn't specific enough. There are lots of marks (Unicode Punctuation, * character categories) that are found in First Names. In Latin-1 alone, periods, parentheses, hyphens, apostrophes, and quotation marks are part of given names as entered on forms. Sure, there are hundreds of other punctuation marks that are not typically part of given names, but you have to ask yourself whether it's worth the penalty of telling people Your name is not your name in order to catch a few outliers. We err on the side of trust; I'm not going to tell someone who enters "Jane #2" that they can't buy a product, while some spam lead who happens to use the first name "Joe" is good. .

Also note that South Indian given names (assigned initials) frequently are only one letter.  It would be wrong to tell someone their effective first name is not "S", because that is their name, and it's not supposed to be spelled out. You'd just be alienating millions of potential leads.

* If anybody is curious about why I didn't use display:none; it's because the forms library must calculate the rendered width accurately.

Do this whenever you want to show a form conditionally (as opposed to load a form conditionally).

Here the named mktoForm element is always loading; otherwise you'd have to switch to  the embed, which is wrong on Marketo LPs.

View solution in original post

Re: If Known User Show Form - Conditional

OP please return to your thread and check replies.

Re: If Known User Show Form - Conditional

Sorry, thank you I've marked your answer as correct.