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

Maintaining Payment Processing Compliance When the Goalpost Keeps Moving

VIRP is the new four-letter word everyone loves to hate. The Visa Integrity Risk Program went into effect last year, and affects several business types — including MCC 5967, which covers adult and anything else with nudity, and MCC 7273, dating services that don’t allow nudity.

Jonathan Corona ·
opinion

Making the Most of Your Sales Opportunities

The compliance road has been full of twists and turns this year. For many, it’s been a companywide effort just to make it across that finish line. Hopefully, most of us can now return our attention to some important things we’ve left on the back burner for months — like driving revenue.

Cathy Beardsley ·
profile

YourPaysitePartner Marks 25-Year Anniversary Amid Indie Content Renaissance

For 25 years, YourPaysitePartner has teamed up with stars and entrepreneurial brands to bring their one-stop-shop adult content dreams to life — and given the indie paysite renaissance of the past few years, the company’s efforts have paid off in spades.

Alejandro Freixes ·
opinion

WIA Profile: B. Wilde

B. Wilde considers herself a strategic, creative, analytical and entertaining person by nature — all useful traits for a “marketing girlie,” a label she happily embraces.

Women In Adult ·
opinion

Proportionality in Age Verification

Ever-evolving age verification (AV) regulations make it critical for companies in the adult sector to ensure legal compliance while protecting the privacy of adults wishing to view adult content. In the past, however, adult sites implementing AV solutions have seen up to a 60% drop in traffic as a result.

Gavin Worrall ·
opinion

Goodbye to Noncompete Agreements in the US?

A noncompetition agreement, also known as a noncompete clause or covenant not to compete, is a contract between an employer and an employee, or between two companies.

Corey D. Silverstein ·
opinion

The Search for Perfection in Your Payments Page

There has been a lot of talk about changes to cross sales and checkout pages. You have likely noticed that acquirers are now actively pushing back on allowing merchants to offer a negative option, upsell or any cross sales on payment pages.

Cathy Beardsley ·
opinion

Unpacking the Payment Card Industry's Latest Data Security Standard

The Payment Card Industry Data Security Standard (PCI DSS) is a set of requirements and guidelines that apply to all businesses that accept credit card payments, and is designed to ensure the security of those transactions.

Jonathan Corona ·
opinion

Compliance With State Age Verification Laws

During the past year, website operators have faced a slew of new state age verification laws entailing a variety of inconsistent compliance obligations.

Lawrence Walters ·
opinion

Merchants in Spotlight With Visa's VIRP

By now, most merchants know about the Visa Integrity Risk Program (VIRP) rolled out in spring 2023. The program is designed to ensure that acquirers and their designated agents — payment facilitators, independent sales organizations and wallets — maintain proper controls and oversight to prevent illegal transactions from entering the Visa payment system.

Cathy Beardsley ·
Show More