educational

More Surfer Redirection Using JavaScript

Quite a readers enjoyed last week's Surfer Redirection Using JavaScript article, and a few of you wanted to know more about using JavaScript to manage your site's traffic. Here are a few more of my favorite redirection scripts, and some suggestions on how to use them...

Referrer Redirect
Being able to redirect surfers based upon the page they came from can provide you with many benefits, including the ability to target advertising and entry pages, as well as language settings and other user-specific enhancements. You can also use this script for a rudimentary security gate, ensuring that visitors to your member's area came through your AVS script page.

Place the following lines inside of your <HEAD></HEAD> tag. You will need to insert the page destination you wish to send the surfer where it says REDIRECTION PAGE as well as your BASE URL; the page that must refer the surfer:

<SCRIPT language="JavaScript">
<!-- Referrer Redirect
function check(){
referingDoc = document.hide.ref.value
if (referingDoc != ("")){
if (referingDoc.indexOf("BASE URL") == -1){;
window.location = "REDIRECTION PAGE"}
}
}
// Referrer Redirect -->
</SCRIPT>

Now put the following lines inside of your <BODY> code:

<BODY onLoad="check()">

Finally, place this code after your <BODY onLoad="check()"> tag:

<FORM name=hide><INPUT type=hidden name=ref></FORM>
<SCRIPT>document.hide.ref.value = document.referrer; </SCRIPT>

New User Redirect
Using cookies to determine if the user has been to your page before, this script redirects first time visitors to a new page. This is really handy for setting up a special greeting or help page.

Put these lines inside of your <HEAD></HEAD> tag, modifying the REDIRECT URL and COOKIE NAME (choose something "unique") to the appropriate values:

<SCRIPT language="JavaScript">
<!-- New User Redirect
var caution = false
function setCookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "")
if (!caution || (name + "=" + escape(value)).length <= 4000)
document.cookie = curCookie
else
if (confirm("Cookie exceeds 4KB and will be cut!"))
document.cookie = curCookie
}
function getCookie(name) {
var prefix = name + "="
var cookieStartIndex = document.cookie.indexOf(prefix)
if (cookieStartIndex == -1)
return null
var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
if (cookieEndIndex == -1)
cookieEndIndex = document.cookie.length
return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}
function deleteCookie(name, path, domain) {
if (getCookie(name)) {
document.cookie = name + "=" +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT"
}
}
function fixDate(date) {
var base = new Date(0)
var skew = base.getTime()
if (skew > 0)
date.setTime(date.getTime() - skew)
}
var now = new Date()
fixDate(now)
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000)
var visits = getCookie("COOKIE NAME")
if (!visits)
location = "REDIRECT URL"
setCookie("COOKIE NAME", visits, now)
// New User Redirect -->
</SCRIPT>

Time Based Redirect
This simple JavaScript alternative to cookie-based solutions will send visitors to a specified URL after a set period of time. This is great for high bandwidth Web pages that you want to limit free access to. Perhaps you could even use it to set up a "limited time free trial" to a webcam or other video feed, sending surfers to the join form for more. The possibilities are endless...

Put these lines inside of your <HEAD></HEAD> tag:

<SCRIPT language="JavaScript">
<!-- Time Based Redirect
function startTimer(){
var time= new Date();
hours= time.getHours();
mins= time.getMinutes();
secs= time.getSeconds();
closeTime=hours*3600+mins*60+secs;
closeTime+=10;
Timer();
}
function Timer(){
var time= new Date();
hours= time.getHours();
mins= time.getMinutes();
secs= time.getSeconds();
curTime=hours*3600+mins*60+secs
if(curTime>=closeTime)
location = "YOUR URL"
else
timeLeft();
}
function timeLeft(){
count = closeTime-curTime;
window.setTimeout("Timer()",1000)
}
// Time Based Redirect -->
</SCRIPT>

Now put the following lines inside of your <BODY> code:

<BODY onLoad="startTimer()">

Finally, change closeTime+=10; to reflect the amount of seconds to wait before page redirect, and change location = "YOUR URL" to the URL you wish to send the surfer.

I hope that you find this collection of surfer redirection tools useful. They can open up new possibilities for your traffic management planning, and help you to increase your profitability. Don't be afraid to experiment, either. Combine bits and pieces of several scripts together and develop a solution unique to YOUR needs. Good luck!

Copyright © 2024 Adnet Media. All Rights Reserved. XBIZ is a trademark of Adnet Media.
Reproduction in whole or in part in any form or medium without express written permission is prohibited.

More Articles

opinion

Navigating Age-Related Regulations in Europe

Age verification measures are rapidly gaining momentum across Europe, with regulators stepping up efforts to protect children online. Recently, the U.K.’s communications regulator, Ofcom, updated its timeline for implementing the Online Safety Act, while France’s ARCOM has released technical guidance detailing age verification standards.

Gavin Worrall ·
opinion

Why Cyber Insurance Is Crucial for Adult Businesses

From streaming services and interactive platforms to ecommerce and virtual reality experiences, the adult industry has long stood at the forefront of online innovation. However, the same technology-forward approach that has enabled adult businesses to deliver unique and personalized content to consumers worldwide also exposes them to myriad risks.

Corey D. Silverstein ·
opinion

Best Practices for Payment Gateway Security

Securing digital payment transactions is critical for all businesses, but especially those in high-risk industries. Payment gateways are a core component of the digital payment ecosystem, and therefore must follow best practices to keep customer data safe.

Jonathan Corona ·
opinion

Ready for New Visa Acquirer Changes?

Next spring, Visa will roll out the U.S. version of its new Visa Acquirer Monitoring Program (VAMP), which goes into effect April 1, 2025. This follows Visa Europe, which rolled out VAMP back in June. VAMP charts a new path for acquirers to manage fraud and chargeback ratios.

Cathy Beardsley ·
opinion

How to Halt Hackers as Fraud Attacks Rise

For hackers, it’s often a game of trial and error. Bad actors will perform enumeration and account testing, repeating the same test on a system to look for vulnerabilities — and if you are not equipped with the proper tools, your merchant account could be the next target.

Cathy Beardsley ·
profile

VerifyMy Seeks to Provide Frictionless Online Safety, Compliance Solutions

Before founding VerifyMy, Ryan Shaw was simply looking for an age verification solution for his previous business. The ones he found, however, were too expensive, too difficult to integrate with, or failed to take into account the needs of either the businesses implementing them or the end users who would be required to interact with them.

Alejandro Freixes ·
opinion

How Adult Website Operators Can Cash in on the 'Interchange' Class Action

The Payment Card Interchange Fee Settlement resulted from a landmark antitrust lawsuit involving Visa, Mastercard and several major banks. The case centered around the interchange fees charged to merchants for processing credit and debit card transactions. These fees are set by card networks and are paid by merchants to the banks that issue the cards.

Jonathan Corona ·
opinion

It's Time to Rock the Vote and Make Your Voice Heard

When I worked to defeat California’s Proposition 60 in 2016, our opposition campaign was outspent nearly 10 to 1. Nevertheless, our community came together and garnered enough support and awareness to defeat that harmful, misguided piece of proposed legislation — by more than a million votes.

Siouxsie Q ·
opinion

Staying Compliant to Avoid the Takedown Shakedown

Dealing with complaints is an everyday part of doing business — and a crucial one, since not dealing with them properly can haunt your business in multiple ways. Card brand regulations require every merchant doing business online to have in place a complaint process for reporting content that may be illegal or that violates the card brand rules.

Cathy Beardsley ·
profile

WIA Profile: Patricia Ucros

Born in Bogota, Colombia, Ucros graduated from college with a degree in education. She spent three years teaching third grade, which she enjoyed a lot, before heeding her father’s advice and moving to South Florida.

Women In Adult ·
Show More