Here’s a script that redirects users to the URL you assigned when they click on the “back” button in the browser. It is intended for extra monetization of traffic on the landing page.
Previously, we published these articles on complete traffic monetization with news showcases:
- https://cpa.rip/stati/easy-additional-monetization – in this article, there’s a script that opens the landing page in a new tab and redirects a user to the product showcase in the original tab when he/she clicks a button on the landing page.
- https://cpa.rip/facebook/additional-monetization – here, we described the method and results of complete monetization by redirecting to the showcase when a user clicks the “Back” button in the browser but the script was not included.
Below, you’ll find an actual script for implementing the latter method:
<script>
(function(window, location) {
var bbURL = 'YOURWEBSITE';
history.pushState(null, document.title, location);
window.addEventListener("popstate", function() {
history.replaceState(null, document.title, location);
setTimeout(function() {
location.replace(bbURL);
}, 0);
}, false);
}(window, location));
</script>
You must insert this script into the source code of your website, replacing “YOURWEBSITE” with the required URL to redirect users. We recommend writing it at the beginning, for example, in front of the <head>
tag so that the code has time to load.