There is an LP, with him the user goes to the site of the goods. When the user on the product website clicks on the "back" button, he goes back to the same LP. How to track the return of the user and direct it to another URL?
- $ _SERVER ['HTTP_REFERER']? - Manitikyl
2 answers
window.addEventListener('popstate', function () { // происходит когда человек жмет кнопку назад window.location = "https://www.test.ru/other/page" }); Honestly, such tricks are just beyond good and evil. Imagine that your grandmother went to such a site, presses the button back and gets on a completely different page. This is not fun at all. Better not to do that.
- I forgot to add that I do not have access to the product site. He leaves my LP and goes to someone else’s site. On another site, I can not place the script and hang the action on the Back button. - Artem
Well, here are a couple of options. Add a link to the button back, the GET Parameter, and check if the parameter is on the page, if any, of the redrektim. If you use the history object built into the browser for the “back” button, then, before sending the user back to another intermediate file, make a request, passing the “Now the user returns to this page, redirect” parameters, let that file records the above described data into the session, and when you revolt the redirect, you delete this data. But in general, of course, it will be easier of course to simply return the user to the link back using $_SERVER['HTTP_REFERER'] adding return parameters to it.
- I forgot to add that I do not have access to the product site. He leaves my LP and goes to someone else’s site. On another site, I can not place the script and hang the action on the Back button. - Artem
- Then the option is to save the cookie, Type "user was here" and every time to check whether this cookie is there or not. - Evgeny Ivanov
- I thought about this option and even did. But, when you go back the script is not executed. The feeling that the page does not load, but is taken from the cache. - Artem