Skip to main content
All CollectionsTechnical questions
How to use return URLs?
How to use return URLs?

Setting up return URLs to control redirections at the end of the action.

Madeleine White avatar
Written by Madeleine White
Updated over 2 months ago

Return URLs are very useful, especially when a subscriber connects while reading an article. After login or subscription, the reader is directly redirected to the page or article from she/he comes. This is very useful to maintain an optimal user experience!

How to set up return URL?

To set up a "return URL", you have to pass an URL parameter on each URL where there is a need to go back. There are two ways to do that:

Option 1:
Putting the following parameter ?returnUrl={return_url} at the end of the URL in the widget creation or settings:

Note: {return_url} is actually a Javascript shortcut function "window.location.href", which allows to recover the URL of the current page.


Option 2:
Directly in your code, adding the parameter at the end of the URL affected

📌 Script Poool - previous version

poool("config", "subscription_url", "http://mysite.com/subscribe?return_url=" + window.location.href);

📌 Script Poool - new version

access.config('subscription_url', 'http://mysite.com/subscribe?return_url=

Both of these solutions involve that you have recovered by yourself the URL information and redirected it on the server or in Javascript in the right moment (post-login or post-registration). Without that, there will be no redirection 😊.

Here is an example you can use to redirect your users :

const urlParams = new URLSearchParams(window.location.search);

const returnUrl = urlParams.get('return_url');

if (returnUrl) {
window.location.href = returnUrl;
}


If you need more information about it, you can contact us on Intercom!

Did this answer your question?