i'm designing a mobile web based e-commerce solution. If the user closes the browser window, items in their cart will be lost (assuming they rejected the initial cookie request) when they return. To prevent this i'm considering prompting the user if they are sure they want to close the browser and would like to create an account . Is this a good way to overcome this issue or is there another way?
Presenting a warning about data loss is always a good idea.
Ameen, one of the most important fundamental rules of good UX design, IMHO, is to make sure that users never unintentionally lose data.
With that in mind, your users will typically navigate away from your site for two reasons:
They decide not to make the purchase, after all.
Presenting the warning might bother the user, but since they already decided to leave your store, that's a potential issue I wouldn't be too concerned about.
They navigate away by mistake (incl. that they incorrectly expect the cart contents to be saved)
If the user does lose their cart contents, you risk to annoy them so much that they are not willing to start over from scratch. Even if they do start over, they will remember what an awful experience that was. As a result, your site will lose reputation and business!
Presenting the alert will prevent that from happening. And it's a small price to pay for the user to have a safe, efficient shopping experience.
Ideally, the system safeguards users' data automatically.
A better solution is, of course, to synchronize any changes to the cart with the server as soon as possible. That way, you don't need to display with a warning at all.
This also addresses the technical issue that it is not always possible to intercept the user navigating away from a page. Just think of someone force-quitting the app if it's frozen…
Never require creating an account during check-out.
One more thing: do not require your site's visitors to create an account in order to complete the purchase. Always — always — allow users to check-out without having to create an account!
Jared Spool's story about the $300 Million Button explains why.
To really "delight" your first-time users, offer to create an account for them after they have entered their address, payment info, etc.
At that point in the user journey, your site has already captured all that data anyway — except for username and password. Choosing just those two data items will feel much less like a burden to your users, than having to enter all that other stuff "just to create an account."