web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

Redirect URL using marketing page/form

(0) ShareShare
ReportReport
Posted on by 522

Hello,

I would appreciate if someone can help in this.

I have created a marketing form of landing type. When someone submits the form it shows thankyou message and redirects to the provided URL(marketing page that contains form -->redirect URL)

Above is working fine.

But how I can redirect to different URL of the Websites. Say for example I have 2 websites (for Florida and California) if someone fills the form from Florida it should redirect to the Website(Florida) and someone who submits the form from California it should redirect to California website.

I have the same question (0)
  • Suggested answer
    cloflyMao Profile Picture
    25,210 on at
    RE: Redirect URL using marketing page/form

    Hi,

    As per my understanding, are you embedding single form to different websites?  Would their URL be something like below?

    megha18florida.com/signup

    megha18california.com/signup

    If so, you can run custom javascript function at afterFormSubmit event of the form using Marketing Form API to redirect to different URLs based on website host name instead of standard redirect settings.

    MsCrmMkt.MsCrmFormLoader.on('afterFormLoad', function (event) {
        var website_name = location.host;
        if (website_name === 'megha18florida.com') {
            location.href = 'Florida website page';
        } else if (website_name === 'megha18california.com') {
            location.href = 'California website page';
        }
    });

    Regards,

    Clofly

  • Suggested answer
    Reneilene Gacusan Profile Picture
    37 on at
    RE: Redirect URL using marketing page/form

    Hi!

    What if the redirect is based from value submitted? 
    Example: 

    Country = PH redirect to URL A
    Country = AU redirect to URL B

  • cjbarnaby Profile Picture
    10 on at
    RE: Redirect URL using marketing page/form

    Hi Reneilene Gacusan ,

    To change the url to which the user is redirected after the form is submitted based on a value in the form, you would follow the basic approach suggested by Clofly, above, but first parse the form to get the value from the relevant input, and then set the window.location.href based on that value. 

    For example:

    MsCrmMkt.MsCrmFormLoader.on("afterFormSubmit", function(event) {
        // Assuming the relevant input has the id "country":
        const countryInput = document.getElementById("country");
        const countryValue = countryInput.value;
        // Assuming the relevant input can have the values "PH" or "AU":
        if (countryValue === "PH") {
            window.location.href = "https://www.example.com/A";
        } else if (countryValue === "AU") {
            window.location.href = "https://www.example.com/B";
        } else {
            // Doesn't hurt to have a fallback:
            window.location.href = "https://www.example.com"
        }
    });

    Make sure your event listener is listening for the afterFormSubmit event, as opposed to formSubmit or any other event emitted by the form loader, since you want to wait until the form has been submitted and processed before sending the user elsewhere. Per the docs, the afterFormSubmit event: 

    Triggers on form submit after the form submission is sent to the server. It triggers only when the submission is successful. It triggers before the redirect or showing the confirmation message.


Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 159

#2
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 152

#3
Tom_Gioielli Profile Picture

Tom_Gioielli 134 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans