Redirecting end users to other url upon ticket submission
Question to the Community: How can I redirect end users to another web site (outside of Zendesk) after they've clicked the Submit button on a ticket form.
Some context might help. We have several forms the end user can choose to fill out. On the new requests page, the end user selects the form they want to fill out from the drop down menu. The form opens, the end user fills it out, and clicks Submit. Normally, the end user is returned to the Zendesk Home Page with a nice message at the top saying their request has been successfully submitted. For one specific form, however, upon completion, we want to redirect the end user to another web site with additional information. This other web site is not part of our Zendesk site.
Scenario: An end user visits our Zendesk site and wishes to submit a request. They click on the Submit a Request link. The end user chooses one of five forms available for them to choose from. The end user selects Form #3. The end user proceeds to fill out the form, then when the end user clicks the Submit button, we want to bring them to https://www.google.com (just using this url as an example). Please keep in mind that we'd also like to capture the data entered into the form as a ticket, and we would not want to apply this redirect to the other forms, only to Form #3.
I'm not a coder by any means. I've attempted various javascript and jquery methods to no avail. I was hoping someone in the Zendesk community might be able to help. below is a sample of the code I'm using. I've tried many other variations of this. I feel like I'm close, but it just doesn't work. The user is still being returned to the Zendesk home page.
(function () {
if(window.location.href.indexOf("ticket_form_id=123456") > -1) {
document.querySelector('input[type=submit]').addEventListener('click', (function () {
(window.location.replace = 'https://www.google.com');
});
});
Thank you for your assistance.
-
Thanks for the context and detail in your question, Edward! I'm no code expert myself, but we'll ping a few folks and see if we can get someone in here who can help you out.
-
Hey Edward -
Update for you: one of our mods is looking into this code for you. He's got a few deadlines looming so it might take a couple of days for him to get back to you, but we've got you covered. :)
-
You guys are the best!
-
@Edward - I took a very quick look and I don't believe we are going to be able to redirect after the submit occurs however we may be able to get the redirect to occur after it takes you to the ticket page. I didn't have time to really dig into the details but I believe that is where you need to look. Hopefully, I will have more time in the next few days.
How long are the instructions as you may be able to show the instructions directly on the ticket page. You could hide HTML on the ticket page then show that HTML based on data on that ticket page. There are a couple of options to think about and play around with.
-
The problem with your code is that it fires immediately when the submit button is pressed not allowing enough time for the PHP functions to properly execute.
I don't know a good solution but you can write javascript code similar to what you have done which triggers on the home page and looks for the "return_to" parameter in the URL. As this parameter is present after a form is submitted. You would also need to use the javascript function document.referrer to check what the previous URL is if you want to only trigger the redirect on a particular form.
The problem with this solution is that it means the Zendesk home page may briefly appear before the redirect is enacted.
Cette publication n’accepte pas de commentaire.
5 Commentaires