Stop Traffic From Bouncing off Your Site with this....

This is not a new thing and many of you will be using it, but i couldn't find the thread i found this on so im posting it in its own thread for anyone that could use it and so i can find it easily in future.

Basically this bit of code stops traffic from leaving your site and instead sends them to any URL of your choice.

I have used this on one site for over 2 years without any problems with ranking. Infact the page i direct my traffic to is sitting at the top of search results for a couple competitive terms and has been for a year or so. And i did little link building to this page so take from that what you will.

Place this code above the [/head] tag in your wordpress editor.

Code:
<script>
var ref = document.referrer;
var siteurl = "http://YOURSITE.COM/";//if you have www, then use www.
if (ref.indexOf(siteurl)!= -1){
}
else{
(function(window, location) {
    history.replaceState(null, document.title, location.pathname+"#!/auth");
    history.pushState(null, document.title, location.pathname);

    window.addEventListener("popstate", function() {
      if(location.hash === "#!/auth") {
        history.replaceState(null, document.title, location.pathname);
        setTimeout(function(){
          location.replace("http://YOURCHOSENURL.COM/");
        },0);
      }
    }, false);
}(window, location));

}</script>

Gracias!
 
Last edited:
Would this really have any effect on rankings anyway? I am not sure. I guess google will track when visitors return to make same queries. For example, if lots of users are clicking on number 1 result and then returning to the results and clicking the number 2 result, Google will take note if this? And maybe also they take note of the period of time between those returns?????

I don't have any examples that prove whether it does or not. However to me, common sense suggests that if visitors often bounce back to search quickly straight from your landing page then they are not finding what they want. That in turn suggests that your landing page is not a good fit for the keyword they used, and in theory Google would be less inclined to want to show your page for that phrase.

All speculation of course.

If we were to assume that bounce back to search has no impact on ranking then this code is only useful if people don't leave the site quickly after you redirect them with the code. If they are still quitting the site immediately after you redirect them then literally all you have done is (artificially) lower the bounce rate, for no other benefit. If a lower bounce rate is what you want, just install two GA codes, that brings it down to about 1% :D.
 
It should not make you rank better or worse since bounce rate is clearly not a metric that matters to google. Pogo sticking is what you should be taking into consideration.

If the used has not found what he was looking for in your webpage, he will end up in google and in another page until he finds what he wants, and that is what google sees.

With this you are just faking the bounce rate of your analytics page, which can be useful when you want to fake that metric specifically for other purpose.
 
It should not make you rank better or worse since bounce rate is clearly not a metric that matters to google. Pogo sticking is what you should be taking into consideration.

If the used has not found what he was looking for in your webpage, he will end up in google and in another page until he finds what he wants, and that is what google sees.

With this you are just faking the bounce rate of your analytics page, which can be useful when you want to fake that metric specifically for other purpose.


Bounce rate matters in rankings, don't fool yourself. Google wana know if a person stays on a site 1 sec or 15 min. If he stay on a website 15 min it is only logical to assume that the party is there.

Also this does not fake the bounce rate but decrease it in reality.
 
Bounce rate matters in rankings, don't fool yourself. Google wana know if a person stays on a site 1 sec or 15 min. If he stay on a website 15 min it is only logical to assume that the party is there.

Also this does not fake the bounce rate but decrease it in reality.

I dont agree with you, maybe I am wrong here, hoping to see more answers from other people.

My point here is, it depends a lot on which niche you are at.

I only work on one, where the natural/average bounce rate is 80%. I have whatsoever no problems for staying atm at #2 for my main keyword. The thing that I still believe is the important is the CTR and pogo sticking, which both are completely related.

Lets say google controls the average CTR for different positions on my main keyword.

When google sees that my ctr for my keyword instead of being 2% (average) is 4% for weeks(it's an example), then it will start asking that why is my page geting so much attention (maybe its because the current #1 doesn't offer a good answer?), and its when it starts making the changes at determinated hour times. CTR can be manipulated aswell ofcourse, and that is in my opinion, a metric that is worth manipulating when it comes to ranking in google, specially when you find yourself in first page.

At least it's what I feel its working in my niche and in my country (spain)
 
CTR and Bounce rate are 2 very important factors. I'm surprised you don't know such basic knowledge.

There are so much videos and topics about this.

I like this one very much. This guy put very nice point, I like his presentations.

The way this script works is not to fool Google. It is to extend the time a visitor spend on your site. And if you build nice landing page you will achieve your goal. Nothing to fake here.

For example I have this website since the beginning of 2017. It is monetized with adsense. Before I use this script the site was making 100-150$ a day. The moment I put the script and made nice landing page I started earning 200-300$ a day. I am using the script since April. Yes It reduces my bounce rate but it does not fake it. It is really working and make the people stay on your site which is very important for google.


"Sexiest Metric ever" XD
 
Last edited:
Thanks for the share ! Just modified it a bit

Code:
var ref = document.referrer;
var siteurl = window.location.origin?window.location.origin+'/':window.location.protocol+'/'+window.location.host+'/';
if (ref.indexOf(siteurl)!= -1){
    
} else {
    (function(window, location) {
        history.replaceState(null, document.title, location.pathname+"#!/auth");
        history.pushState(null, document.title, location.pathname);
    
        window.addEventListener("popstate", function() {
          if(location.hash === "#!/auth") {
            history.replaceState(null, document.title, location.pathname);
            setTimeout(function(){
              location.replace(siteurl);
            },0);
          }
        }, false);
    }(window, location));
}
So now it's taking the root url without anything to edit, copy and paste and you are good to go ...

if the current page is https://www.example.com/test-page the redirect will go to https://www.example.com

if the current page is http://example.com/test-page the redirect will go to http://example.com
 
Thanks for the share ! Just modified it a bit

Code:
var ref = document.referrer;
var siteurl = window.location.origin?window.location.origin+'/':window.location.protocol+'/'+window.location.host+'/';
if (ref.indexOf(siteurl)!= -1){
   
} else {
    (function(window, location) {
        history.replaceState(null, document.title, location.pathname+"#!/auth");
        history.pushState(null, document.title, location.pathname);
   
        window.addEventListener("popstate", function() {
          if(location.hash === "#!/auth") {
            history.replaceState(null, document.title, location.pathname);
            setTimeout(function(){
              location.replace(siteurl);
            },0);
          }
        }, false);
    }(window, location));
}
So now it's taking the root url without anything to edit, copy and paste and you are good to go ...

if the current page is https://www.example.com/test-page the redirect will go to https://www.example.com

if the current page is http://example.com/test-page the redirect will go to http://example.com
Nah it is a free service site for Instagram.
I am getting a problem, I added the scripts and then when I press back button, I get directed to yourchosenurl.com .i have put my url in 2 places where you have written 'yoururl' Now after I removed the code, I am still getting redirected to yourchosenurl.com Any help?
 
I am getting a problem, I added the scripts and then when I press back button, I get directed to yourchosenurl.com .i have put my url in 2 places where you have written 'yoururl' Now after I removed the code, I am still getting redirected to yourchosenurl.com Any help?

yay u for 99% have cloudflare/wp rocket or other unpleasing caching system.

sometimes here i dont see changes even after wiping all cache+using different browser in incognito mode so i just check with phone if site is rendering well or not
 
yay u for 99% have cloudflare/wp rocket or other unpleasing caching system.

sometimes here i dont see changes even after wiping all cache+using different browser in incognito mode so i just check with phone if site is rendering well or not
You are right, It scarewd the shit outta me. Meanwhile I got another error, looks like I removed some part of code while I was removing this script lol
 
You are right, It scarewd the shit outta me. Meanwhile I got another error, looks like I removed some part of code while I was removing this script lol

If u have a backup from today just use it. Ofc depends on how dynamic your site is.
 
I am getting a problem, I added the scripts and then when I press back button, I get directed to yourchosenurl.com .i have put my url in 2 places where you have written 'yoururl' Now after I removed the code, I am still getting redirected to yourchosenurl.com Any help?
You have nothing to replace if you use my code, the javascript will find your root url by itself.

I just updated the code to deploy this on several websites without editing the code for each site. It's working fine for me.

And as @aidenhera suggested this a caching issue for sure
 
@amandine both your and original code in my case (tested on 2 WP blogs) works just once. meaning if they are on inner page and press back it will bring them to root page, but if they press back again then they will land in Google. Not sure why is that unless it was supposed to stop them just once? I have code before </head> on every page.
 
i placed it just after <head> with http instead of https and it works (unless i press back button too fast)

Anyway good script :)
 
This is the same "trick" Amazon uses to keep people on their site when you click the back button. I don't see what good this does considering I still leave their website by clicking the X on the tab. Once I got a clue of what they were doing, I stopped shopping with them.
 
Nothing makes me exit a browser quicker than someone taking control if it to push me into seeing what they want.

Thank you! Like, wtf? Why don't you just put something on the page worth looking at if you want me to stay. If people spent more time offering value, instead of playing tricks, they would not have to worry about their bounce rate.
 
i have another question, sirs
will fb block my ad account if i promote a link with this thing?
 
Back
Top