I was wondering how, after a form submission, I can redirect users to different Thank You pages based on their IP address.
So, when someone submits the form:
If IP Country = Italy --> Show IT thank you page
If IP Country = Greece or France --> Show the EN thank you page
If IP Country = Other than the above --> Show a different EN thank you page from the one mentioned above
Hey @Gea you’re going to need to do some custom coding on the landing page.
First, you need a field to the form (like a hidden field) to store/capture the country code.
Then in the advance settings of the page in the footer section, use this script and modify to get the country code from the hidden field and do a custom redirect if needed.
<script>
window.addEventListener('message', function(event) {
//HubSpot Form Submission
if(event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormSubmit') {
//Need to look at a hidden value or something that says country code.
//Set your form to normally redirect to the EN page.
if( country === "IT" ) {
window.location.href = '{{insert language specific}}';
}
}
});
</script>
To redirect users to different Thank You pages based on IP after a form submission, you can use a server-side scripting language such as PHP or ASP.NET. Here’s an example code snippet in PHP with parkingarea word example:
In this example, the user’s IP address is obtained using the $_SERVER[‘REMOTE_ADDR’] variable. Then, an if-else statement is used to check if the IP address matches a specific value. Depending on the result of the check, the user is redirected to one of two different Thank You pages on the parking website.
Note that this code should be placed on the server-side processing script that handles the form submission. Also, remember to replace the example website parkingarea.com with your own website’s domain name.