Top > Affiliate Marketing > pop-ups with cookies

Pop-ups are combined with cookies to prevent the pop-up window from opening again to a visitor that has already seen it.

Ideally, you want your pop-up on every page of your site, because visitors will enter and exit through different pages. Unfortunately, doing that using a standard pop-up script is going to annoy people. Why?

Because a pop-up window will open every time they move from one page to another!


adding cookies to your pop-ups

A cookie is a small data file placed into the visitor's Web browser. Cookies are used to store various kinds of user-specific information that enable a Web site to distinguish one visitor from another. It could be a logon password, affiliate ID, customer ID, etc. In our case, we only need to record when the pop-up is allowed to appear to this visitor again.

The pop-up script below incorporates a function to check for a particular cookie in the visitor's browser. If the cookie isn't found, the script will create it, and simultaneously fire the pop-up window. If the cookie is located, the script will use the data stored there to decide wether or not it should open the pop-up.

Imagine a new visitor arriving at a page on your site. Her browser doesn't yet have your cookie, so the pop-up window opens and a cookie is written. When she moves on to another page, the pop-up script on this page also checks for your cookie, and finds the one created earlier. The cookie tells the script that your visitor has already seen the pop-up window, and that not enough time has passed to allow it to display the pop-up to her again. The same thing happens on every subsequent page she visits

She will never see the pop-up again until the amount of time you specify (in the script) has elapsed. That's usually one day, but if you have a lot of daily repeat traffic, you might want to set a longer interval.

Due to the more complex nature of this script, I suggest you become familiar with standard pop-ups first.

pop-up script with cookies that opens when visitors enter a page

Place the following script between the <HEAD> and </HEAD> tags:

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
var expDays = 1; / number of days the cookie should last
var page = "subscribe.html"; /URL to the pop-up
var windowprops = "width=200,height=200,location=no,
toolbar=no,menubar=no,scrollbars=no,resizable=no"; / variables
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function amt(){
var count = GetCookie('count')
if(count == null) {
SetCookie('count','1')
return 1
}
else {
var newcount = parseInt(count) + 1;
DeleteCookie('count')
SetCookie('count',newcount,exp)
return count
}
}
function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}

function checkCount() {
var count = GetCookie('count');
if (count == null) {
count=1;
SetCookie('count', count, exp);

window.open(page, "", windowprops);

}
else {
count++;
SetCookie('count', count, exp);
}
}
/ End -->
</script>

And add the following into your <BODY> tag:

onLoad="checkCount()"

Your <BODY> tag should then look something like this:

<BODY bgcolor="#ffffff" text="#000000" onLoad="checkCount()">

 

pop-up script with cookies that opens when visitors leave a page

Just change the script above so that the pop-up opens when your visitor leaves, rather than when they enter the page. It's easy!

In your <BODY> tag simply replace "onLoad" with "onUnload" like this:

onUnload="checkCount()"

 

TrackBacks

Trackback's URL:
http://www.seikokaiun.com/mt3/mt-tb.cgi/4106

Post Comment

(いままで、ここでコメントしたことがないときは、コメントを表示する前にこのブログのオーナーの承認が必要になることがあります。承認されるまではコメントは表示されません。そのときはしばらく待ってください。)

Category


◆ビジネス系
ブログアフィリエイトで稼ぐ日給8万円
ブログアフィリエイトで世界一周旅行
はるちゃんのネットで得しちゃおう!
超時短!1日1万円ブログアフィリエイトで稼ぐ私 の方法
アフィリエイト情報 Rich Rich
実践!情報商材アフィリエイトで稼ぐ
+100 万円副業収入術
ブログアフィリエイトで愛でいっぱいのお金持ちに なる方法
副収入100 倍計画書
ネットで得とく副収入
小遣い倍増計画
ちょっぴりおこづかいカフェテリア
投資で自己実現
競馬投資術
株達人ドットコム
内職バイトで高収入!道楽庵
徹底比較 外為会社
本当にオートサーフ&HYIP で稼げるの?!
◆検索エンジン系
モーニングサーチ
総合検索エンジン・Discovery.Search! サーチエンジン
◆HP 製作系
ホームページ製作ドットコム
web デザイナーが作るフリーホームページ素材
ホームページ製作会社グリーンステップ
Add to Google Add to My Yahoo!
Discount sale now! 50 Things In Common Successful people