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

Strategic Upscaling of Non-4K Content

If content is king in adult, then technical quality is the throne upon which it sits. Technical quality drives customer acquisition and new sales, while cementing retention and long-term loyalty.

Brad Mitchell ·
profile

'Traffic Captain' Andy Wullmer Braves the High Seas as Spirited Exec

Wullmer networked and hobnobbed, gaining expertise in everything from ecommerce to SEO and traffic, making connections and over time rising through the ranks of several companies to become CEO of the mobile business arm of TrafficPartner.

Alejandro Freixes ·
opinion

To Cloud or Not to Cloud, That Is the Question

Let’s be honest. It just sounds way cooler to say your business is “in the cloud,” right? Buzzwords make everything sound chic and relevant. In fact, someone uninformed might even assume that any hosting that is not in the cloud is inferior. So what’s the truth?

Brad Mitchell ·
opinion

Upcoming Visa Price Changes to Registration, Transaction Fees

Visa is updating its fee structure. Effective April 1, both the card brand’s initial nonrefundable application fee and annual renewal fee will increase from $500 to $950. Visa is also introducing a fee of 10 cents for each settled transaction, and 10 basis points — 0.1% — on the payment volume of certain merchant accounts.

Jonathan Corona ·
opinion

Unpacking the New Digital Services Act

Do you hear the word “regulation” and get nervous? When it comes to the EU’s Digital Services Act (DSA), you shouldn’t worry. If you’re complying with the most up-to-date card brand regulations, you can breathe a sigh of relief.

Cathy Beardsley ·
opinion

The Perils of Relying on ChatGPT for Legal Advice

It surprised me how many people admitted that they had used ChatGPT or similar services either to draft legal documents or to provide legal advice. “Surprised” is probably an understatement of my reaction to learning about this, as “horrified” more accurately describes my emotional response.

Corey D. Silverstein ·
profile

WIA Profile: Holly Randall

If you’re one of the many regular listeners to Holly Randall’s celebrated podcast, you are already familiar with her charming intro spiel: “Hi, I’m Holly Randall and welcome to my podcast, ‘Holly Randall Unfiltered.’ This is the show about sex, the adult industry and the people in it.

Women In Adult ·
trends

What's Hot Now: Leading Content Players on Trending Genres, Monetization Strategies

The juggernaut creator economy hurtles along, fueled by ever-ascendant demand for personality-based authenticity and intimacy — yet any reports of the demise of the traditional paysite are greatly exaggerated.

Alejandro Freixes ·
opinion

An Ethical Approach to Global Tech Staffing

One thing my 24-year career as a technologist working to support the online adult entertainment industry has taught me about is the power of global staffing. Without a doubt, I have achieved significantly more business success as a direct result of hiring abroad.

Brad Mitchell ·
opinion

Finding the Right Payment Partner

Whenever I am talking with businesses that are just getting started, one particular question comes up a lot: “How do I get a merchant account?” It’s a simple question, but it has a complicated answer.

Jonathan Corona ·
Show More