Skip to main content

Can I redirect the on-site survey page once it has been submitted?

S
Written by Steve Jones
Updated over 4 months ago

Although this can't be achieved within the settings of the Grapevine Surveys app, there is a very quick and efficient way to redirect from the survey URL by latching on to a javascript event that is fired once a survey has been submitted.


How do I implement this?

By adding the following snippet of javascript to the bottom of your theme.liquid template (or a more suitable location if you have one) you will achieve the desired result:

<script>
document.addEventListener("grapevine:standalone-survey-submitted",
function(event) {
window.location.href = "https://example.com/my-url-1"; // Replace with your target URL
});
</script>

Amend the URL you'd like to redirect to accordingly.

Place the code at the bottom of your theme.liquid file before the closing </body> tag and then save the file

What if I have multiple on-site surveys?

If you're using a number of on-site surveys to collect feedback at different stages of the customer journey, then you may want to redirect respondents to a different page per survey.

To target a specific on-site survey, you will first need to locate its unique survey code (How do I find my unique survey code?)

Once you have the unique survey code, use the javascript below instead of the javascript provided above:

document.addEventListener("grapevine:standalone-survey-submitted", function(event) {
if (event.detail.survey_code === '1a2c3tde456') {
window.location.href = "https://example.com/my-url-1"; // Replace with your target URL
}
if (event.detail.survey_code === '7cb293ad3b4') {
window.location.href = "https://example.com/my-url-2"; // Replace with your target URL
}
if (event.detail.survey_code === '692t2c39ec') {
window.location.href = "https://example.com/my-url-3"; // Replace with your target URL
}
});

Add as many if statements as you need, one for each on-site survey.

Replace the example survey code 1a2c3tde456 with your own unique survey code and remember to change the the redirect url for each survey.

Need any help?

If you have any questions about on-site survey pages or any other Grapevine Surveys related questions, then please do just get in touch.

Did this answer your question?