Redirect form submission based on domain of email | Community
Skip to main content
Level 2
March 13, 2026
Question

Redirect form submission based on domain of email

  • March 13, 2026
  • 2 replies
  • 53 views

I’m trying to do a redirect based on the email domain that they submitted, basically want to redirect them to page A if their non-customer domains, page B if their customer domains. As i know currenly there is no native functionality to cross check the domain to marketo lists correct? Or is there an alternative for this

    2 replies

    AmitVishwakarma
    Community Advisor
    Community Advisor
    March 13, 2026

    Hi ​@ProcessUnity2X 
    Once your user is on an API‑enabled Sign account again (enterprise or developer), the Developer/API section and your Application List will reappear.

    Recommended approach: handle it in client‑side JavaScript after a successful form submit:

    For a Marketo Form (Forms 2.0 API example):

    MktoForms2.whenReady(function(form) {
    form.onSuccess(function(vals) {
    var email = vals.Email || "";
    var domain = (email.split("@")[1] || "").toLowerCase();
    var customerDomains = ["customer.com", "bigcustomer.com"]; // your list

    if (customerDomains.indexOf(domain) > -1) {
    window.location.href = "/page-b-customer.html"; // customer page
    } else {
    window.location.href = "/page-a-noncustomer.html"; // non-customer page
    }
    return false; // prevent default Marketo redirect
    });
    });

    The same pattern works on an AEM page embedding the Marketo form, or with an AEM/EDS form using your own submit handler: parse email domain -> check against a maintained list -> redirect to page A or B.

    • If you want the domain list centrally managed in Marketo, you can:
      • Use Smart Campaigns / Segmentation to set a hidden field like customer_type based on email domain, then
      • In onSuccess, read that hidden field and redirect accordingly (still custom JS, just no hardcoded domains in the page).
    • There's no out‑of‑the‑box "filter by Marketo list then redirect," so custom JS logic on form success is the correct and supported solution.
    Amit Vishwakarma - Adobe Commerce Champion 2025 | 16x Adobe certified | 4x Adobe SME
    Level 2
    March 16, 2026

    Hi, ​@AmitVishwakarma thanks for the explanation. I just wanted to clarify a few things:

    1. Is there a way for a Marketo Forms 2.0 form to dynamically reference domains stored in Marketo (for example from a Smart List, static list, or segmentation) at the time of form submission?

    2. If we maintain customer domains inside Marketo, can the form script query or reference that list dynamically instead of hardcoding the domains in JavaScript?

    3. You mentioned using Smart Campaigns or Segmentation to populate a hidden field like customer_type. Could you share how that setup would typically work in Marketo for this use case?

    4. If referencing a Smart List dynamically isn’t supported, would the recommended approach be to maintain the domain list externally (for example in a JS or JSON file) and reference that from the form script?

    Thanks.

    Level 2
    March 19, 2026

    Hi ​@AmitVishwakarma any word or help we can get regarding our questions? Replies are much appreciated on the matter.

    partyush
    Community Advisor
    Community Advisor
    April 3, 2026

    Hi ​@ProcessUnity2X 

    Marketo Smart Campaigns and Segmentations are asynchronous. If a new user (anonymous) submits your form, Marketo’s server-side processing usually takes 2–5 seconds to identify the domain and update the "Customer Type" field. Your onSuccess JavaScript fires in milliseconds. This means the hidden field will be empty for almost every new lead, and your redirect will fail.

    The way to do this at the moment of submission is to handle the logic in the browser.
    Don't hardcode the domains directly inside your main script logic that's messy. Instead, maintain a clean array or fetch a JSON file, and use the onSuccess handler to intercept the flow.

    The Implementation:

    MktoForms2.whenReady(function(form) {
    form.onSuccess(function(vals, followUpUrl) {
    // 1. Get the email and isolate the domain
    var email = vals.Email || "";
    var domain = email.split('@')[1] ? email.split('@')[1].toLowerCase() : "";

    // 2. Define your customer domains (Keep this clean)
    var customerDomains = [
    "adobe.com",
    "microsoft.com",
    "google.com"
    ];

    // 3. Logic-based Redirect
    if (customerDomains.indexOf(domain) > -1) {
    window.location.href = "https://your-site.com/welcome-customers";
    } else {
    window.location.href = "https://your-site.com/welcome-prospects";
    }

    // 4. Return false to prevent the default Marketo redirect
    return false;
    });
    });

    Note : If you have hundreds of domains, simply host a small domains.json file on your AEM/CDN and fetch it at the top of your script. It's much easier to update a JSON file than a dozen Marketo Smart Campaigns.

    If you are worried about "Customer A" seeing "Customer B's" list in the source code, you can move this logic to an AEM Servlet. The form submits to AEM, the Servlet checks the domain against a secure database/list, and returns the redirect URL. 

    Thank
    Partyush