Go Back   WarriorForum - Internet Marketing Forums > The Warrior Forum > Adsense / PPC / SEO Discussion Forum
Register Blogs FAQ Social Groups CalendarHelp Desk

Reply
 
LinkBack Thread Tools
Old 06-11-2011, 09:17 PM   #1
Warrior Member
 
Join Date: Jun 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default adsense script to prevetn click bombing

ok i googled a bit for this.and found one.but my prob is i dont understand javascript so plz help me with this script...


<div id="banners" onclick="trackclick();">

<script language="JavaScript">

if ( clickCount > 2 ){
document.write('
<a href="your clickbank link or anything else">
<img src="anything replacing adsense ad">
</a>
');
}else{
document.write('
adsense code goes here
');
}

</script>
</div>


now javascript handler for this

<script language="JavaScript">

var clickCount = readCookie();
if ( clickCount == null ){
clickCount = 0;
}

function trackclick() {
clickCount = parseInt(clickCount)+1;
setCookie( clickCount, 2 );
return true;
}

function setCookie( cookieValue, nDays) {
var today = new Date();
var expire = new Date();
if (nDays==null || nDays==0) nDays=1;
expire.setTime(today.getTime() + 3600000*24*nDays);
document.cookie = "clicktrack="+escape(cookieValue)
+ ";expires="+expire.toGMTString();
}

function readCookie() {
var nameEQ = "clicktrack=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0){
return c.substring(nameEQ.length,c.length);
}
}
return null;
}

</script>

now i really dont understand this ndays concept..when will the cookies actually expire.i mean what time frame ? 24 hours or what ? plz help me guys...i need to ensure this thing before using the script....thanks in advance warriors
dabeast is offline   Reply With Quote
Old 06-12-2011, 12:07 AM   #2
SEO Strategist
War Room Member
 
yukon's Avatar
 
Join Date: Jun 2010
Posts: 6,532
Thanks: 355
Thanked 1,992 Times in 1,273 Posts
Default Re: adsense script to prevetn click bombing

I think the code you posted will set the cookie date/time for 1-hour.

3600000 milliseconds * 1000 = 60 (minutes)

I would use php (server side) instead of all javascript.

yukon is offline   Reply With Quote
Reply

  WarriorForum - Internet Marketing Forums > The Warrior Forum > Adsense / PPC / SEO Discussion Forum

Tags
adsense, bombing, click, prevetn, script

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -6. The time now is 05:48 AM.