A simple javascript code that can reduce your bounce rate. What is bounce rate? By Mathematical formula the bounce rate is=Total number of bounces across all the pages on the website in a given time/ Total number of entries across all the pages on the website on the same time * 100
Example: Suppose if you have 100 pages. For a given period of bounce rate calculation, your number of entries pages is 80, say after first visiting your web pages, out of 80, 70 users leave your site immediately, then your total number of bounces is 70. So, your Bounce Rate will be 70/80*100=87.5
Which is a very high rate bounce rate. Note that the bounce rate for a regular blog below 50% is normal but above 50% bounce rate is worrying. There are more options to reduce the bounce rate. These non-technical methods to do so. Today we will show to reduce bounce rate using the javascript redirect method.
Step 1:
Create a folder in the root directory in your website say, www.yoursite.com/reduce-bounce/
Step 2:
create a new file with .js extension, say it is redirect.js
Step 3:
Put the code given below in the redirect.js file and change the URL located at location.replace(“www.yoursite.com/your-new-post“); with your desired post. Upload the redirect.js script in the folder called www.yoursite.com/reduce-bounce/
To verify you may locate the script by entering the full URL www.yoursite.com/reduce-bounce/redirect.js
If you see the code, you have successfully installed the reduced bounce rate script.
(function(window, location) { history.replaceState(null, document.title, location.pathname+"#!/history"); history.pushState(null, document.title, location.pathname); window.addEventListener("popstate", function() { if(location.hash === "#!/history") { history.replaceState(null, document.title, location.pathname); setTimeout(function(){ location.replace("www.yoursite.com/your-new-post"); },0); } }, false); }(window, location));
Step 4:
After that put this small javascript line in the posts that you want to redirect.
<script src="www.yoursite.com/reduce-bounce/redirect.js"></script>
Thus you can create multiple redirection javascript files inside the folder and redirect them to a different post.
For the demo, if you click on the back button of this post, it will redirect to our home page.
Example Result:
Thanks you so much I am using blogger will you please help me that how to put these script in blogger. .
Goto themes, revert to class themes then you can put this script. But you should keep the javascript on third party server location because blogger doesn’t allow to upload files directly.
How to use in WordPress platform. Plz, help me.
This post is platform independent.
Thanks, bro but will it help if I use Blogspot platform?
Yes, it will help.
Man, You’re a rockstar