Forum Moderators: coopster

Message Too Old, No Replies

1 in 10 visitors script

         

tommy2toes

6:27 pm on Jun 27, 2005 (gmt 0)

10+ Year Member



Hi all,

I am new to the php thing, just learning...

Anyways I have searched everywhere for a script but can't seem to find it or even know if it can be done.

I want a script that will make a pop up window for every 1 and 10 visits to the site, by anyone.

any help on this would be much appreciated.

T

moltar

6:38 pm on Jun 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's not very easy nor efficient to do it this way. It'd be easier and faster to generate a number between 1 and 10 and display a pop up if certain, predefined number occurs.

If you want to be really exact and show to exactly every 10th user, then you need to write a counter value into a file with each visit and then once you reach 10, reset the counter and display the pop up.

tommy2toes

6:57 pm on Jun 27, 2005 (gmt 0)

10+ Year Member



Thanks for the response, it doesn't need to be that exact just as long as 10% of people are getting it.

Longhaired Genius

6:59 pm on Jun 27, 2005 (gmt 0)

10+ Year Member



Or to trigger a script for 10% of your visitors you could use this:

$seconds = date('s');
if (preg_match('/0[1-6]/', $seconds)) {
do_something;
}

[Publication of this code should not be construed as conveying approval for unrequested popups of any sort.]

Welcome to Webmaster World.

dreamcatcher

10:38 pm on Jun 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could also use cookies and set a count so that when the cookie hit certain amounts it would display the pop up. At 10, you could reset it back to 0.

dc

moltar

10:45 pm on Jun 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I also thought about cookies at first, but then re-read the requirements and noticed the following:

1 and 10 visits to the site, by anyone.

Thus cookies would not work, because they are user-specific.

jatar_k

10:54 pm on Jun 27, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld tommy2toes,

you could just use a straight up hit counter on the page

everytime it is divisible by 10 -> popup

tommy2toes

5:25 pm on Jun 28, 2005 (gmt 0)

10+ Year Member



^ thanks for the suggestions. That one seems simplest so far...

I will see if I can write it with my limited php skills.

tommy2toes

6:11 pm on Jun 28, 2005 (gmt 0)

10+ Year Member



Okay, after a few hours of searching on google I actually found what I was looking for:

[pcmag.com...]

As much as I hate pop-ups...I have to do one. At least it will be what I refer to as a "ethical pop-up". ie. only 1 in 10 users see it, and when they see it I set a cookie on their machine to never see it again.