0

I have a form that collects data. Once the data has been collected, the user is presented with a screen giving them some information and requesting them to click the final link on the page.

I don't want to just redirect them because the information they are given is important. However, I've noticed that quite a few users are not clicking the link and exiting the page via other means.

This is causing me serious issues - degrading service levels with affiliate partners and putting me at risk of suspension.

I'm not a fan of manipulating the user journey but there is no valid reason to click away at this point, so I would like to look at redirecting them automatically if they do anything to exit the page other than click the link.

After much Googling, I've come up with the window.onbeforeunload function, but I'm not sure this will do exactly the job I need.

Looking for ideas to achieve this functionality, or alternatively do it via another viable method.

All advice appreciated.

dotnetnoob
  • 10,783
  • 20
  • 57
  • 103
  • If a user wants to leave a page, they can - there's nothing you can do as a developer to prevent that. `onbeforeunload` allows you to display a message to the user (in most browsers, Firefox have decided that it's a "security issue" without expanding on that point), but they can still choose to leave. Perhaps you could redirect after a short delay instead, using `setTimeout`? – James Thorpe Mar 06 '15 at 13:46
  • I don't know what the redirect is supposed to do, but maybe placing an iframe on your page could help. As soon as the message is displayed, you could redirect that iframe to the given url, and there is no need for the user to click the redirect anymore. – Michel Mar 06 '15 at 13:47
  • Open a new window if the link is not clicked and they leave the page. [take a look here](http://stackoverflow.com/a/16635526/1685196) – Michel Mar 06 '15 at 14:57

1 Answers1

0

I would not rely on any kind of client-side functionality to ensure such a thing.

Unless there is some extra input you need from the user after seeing the "information screen" then I would just perform all needed actions server-side, before presenting the "information screen" to the user.

CyberDude
  • 8,541
  • 5
  • 29
  • 47
  • Unfortunately I can't present the information needed easily in the flow. What I would say is that this is the belt and braces solution - in most cases the user should click the link anyway. – dotnetnoob Mar 06 '15 at 13:50
  • I'm having a bit of trouble understanding your scenario. So far I see it as: user performs some action -> server performs work A and returns information page -> user clicks link -> server performs work B. So my suggestion is to just perform both work A and work B together if there is nothing the user can do to affect work B in between A and B. – CyberDude Mar 06 '15 at 14:00
  • Sorry, that's exactly the case. User completes form and submits data. Webservice makes contact with partner site and returns results which are presented to user. A link is presented to the user so that they can follow and get the offer. Offers are unique so the webservice need to return the link before next stage. I could just redirect, but consider someone might click submit, do something else or leave the computer, and then return to find a different website open with no explanation. – dotnetnoob Mar 06 '15 at 14:07
  • But if they don't click then wouldn't it mean they don't want the offer? Is that not a valid scenario? – CyberDude Mar 06 '15 at 14:23
  • No. They spend 10 minutes completing a form, clich submit, get a message back to say they were successful and given a link to click. The liklihood of changing their mind after taking that amount of time and being presented with a link saying you got what you wanted, is very small. – dotnetnoob Mar 06 '15 at 14:29
  • And does that extra click do anything on your server or it's a simple link to a 3rd party website? – CyberDude Mar 06 '15 at 19:37