Real time redirect on the basis of specific field

Ajay_Mamgain2
Level 3

 I would like to re-direct lead on the basis of known pre-filled field in Marketo's landing page. In our case, we have created a triggered smart campaign in Marketo to update a boolean field , if the lead belongs to a specific domain. We have already tried applying a delay in form submit however got no success and also we have tried submitting hidden form in 2nd landing page, but we are still not  able to get the desired result. We want the redirect to happen in real time basis only and also we have more than 150 domains. Any help would be appreciated. ?

24 REPLIES 24
Ajay_Mamgain2
Level 3

Thank you for the suggestion.Sanford Whiteman‌ Do you think it can under hundreds of Email domains ? 

@Jay Jiang Can you elaborate on the solution ? Do I have to create a Json object and reference the domain from form fill to that and redirect on the basis of that. 

SanfordWhiteman
Level 10 - Community Moderator

Thank you for the suggestion.Sanford Whiteman Do you think it can under hundreds of Email domains ?

Yes, although I won't deny the UI gets unwieldy.

There's nothing wrong with using an onSuccess listener if you don't care about disclosing the list.

.

Ajay_Mamgain2
Level 3

I tried using the Advance URL thank you setting, however i was not able to include all domain in single if choice using (";" or "," ) separator do we have to create separate if choice for each domain  i.e. 150 choices . You are correct we don't want to disclose the domains and also majority of the users are using IE.

SanfordWhiteman
Level 10 - Community Moderator
I tried using the Advance URL thank you setting, however i was not able to include all domain in single if choice using (";" or "," )

The Advanced Thank You page, unfortunately, doesn't offer the same ease-of-use as the Visibility Rules page, though both are within the Form Editor module.

With VRs, you can use [Contains] and a regular expression. So not separated by ; or , but using the alternator | character as in

 @example1.com$|@example2.com$|@example3.com$

which has the same result of matching multiple domains with one rule.

But with Advanced TY you need separate [Ends With] choices.

Jay's JS approach can easily be made to work w/IE and to do the case-insensitive match. But it will always reveal the domains if someone is curious.

Ajay_Mamgain2
Level 3

I tried the method which you have mention and  included the alternator with ending in regular expression however it is not working for us. 

SanfordWhiteman
Level 10 - Community Moderator

I was mentioning regex to say it doesn't work for Advanced Thank You even though it does work in other parts of Form Editor.

Ajay_Mamgain2
Level 3

So how should i proceed in this case without exposing the domains and redirect the leads on the basis of domain using Advanced Thank you page ?

SanfordWhiteman
Level 10 - Community Moderator
So how should i proceed in this case without exposing the domains and redirect the leads on the basis of domain using Advanced Thank you page ?

Create different Choices.

However, there's another method that occurred to me late last night, and that's pre-hashing (SHA-1 is fine for this) all the domains in your list and then pasting the list of hashes into the {{my.token}} as Jay begins to outline above.

Lookup the hash of the domain in the list of hashes. 

This method will conceal the actual domains, but the lookup will work. If you need only IE11+ support you can do this without any other libraries; if you need IE10 or earlier you'll need a separate JS library, though there are many fine open-source versions of SHA-1.

Jay_Jiang
Level 10

I thought of this too, but it would become an onerous task to check what domains you've included if you're looking through hashed values. Also, if you're going to do this, I'd store the array in an external js file that is included in a master landing page template rather than a token

I'm going to advise again, if you have the resources for it, consider doing an ajax POST to an endpoint in your forms js

SanfordWhiteman
Level 10 - Community Moderator
I thought of this too, but it would become an onerous task to check what domains you've included if you're looking through hashed values. Also, if you're going to do this, I'd store the array in an external js file that is included in a master landing page template rather than a token

 

I'm going to advise again, if you have the resources for it, consider doing an ajax POST to an endpoint in your forms js

Not at all. You maintain the list without the hashes, it takes one click to map to the list of hashes. That's the way anything like this is built.

It would be ridiculous to try to look through hashes -- but there's absolutely no reason for anyone to ever do that.

Ajay_Mamgain2
Level 3

I used this in Advance Thank you page however leads are not getting redirected.

@example1.com$|@example2.com$|@example3.com$
SanfordWhiteman
Level 10 - Community Moderator

Ajay, this syntax doesn't work for Advanced Thank You. It is not surprising that it does not work.

Ajay_Mamgain2
Level 3

Is there any other way to achieve this without exposing the list domains ? 

Jay_Jiang
Level 10

an array will work, e.g. ["domain1.com","domain2.com","domain3.com"], in a text token like {{my.domainsList}}

example (take this as pseudo code)

MktoForms2.loadForm("//app-###.marketo.com", "###-###-###", ###, function(form) {
var domainsList = {{my.domainsList}};
form.onSuccess(function(values, followUpUrl) {
var vals = form.vals(),
email = vals.Email,
domain = email.replace(/.*@/, "");
if(domainsList.includes(domain)){
location.href = "/alternate-thankyou-page";
return false;
}
});
});
SanfordWhiteman
Level 10 - Community Moderator
  • Don't forget that Array#includes isn't supported in any version of IE. You need to use indexOf, find, or a polyfill.
  • That needs to be a case-insensitive lookup so includes isn't suitable anyway..
  • The follow-up URL, assuming it's going to be a Marketo-hosted LP, needs to have the aliId reappended to maintain the usual forms functionality.
Jay_Jiang
Level 10

suggest you do your redirect using forms js.

keep your list of domains in a root level token so it scales

SanfordWhiteman
Level 10 - Community Moderator

I would usually agree and push toward an onSuccess listener, but a major advantage of using Advanced Thank You (when you can) is that you hide the rules from end users. So if it's a list of VIPs or blacklisted domains or something like that, better for it not to be inspectable.

Jay_Jiang
Level 10

yes, if you have one or two forms to maintain, use the thank you page choices

but if you need scaleability, while wanting to hide the list of domains, you can add an ajax call in your form's onsubmit to an endpoint that does the checking

SanfordWhiteman
Level 10 - Community Moderator

Well yeah, but that's not in Marketo anymore, so pretty far outside the realm of what's being contemplated here.

Ajay_Mamgain2
Level 3

Yes you are correct that eventually we want to make a thank you URL conditional on the basis of Email address domain which they have just entered in a form.