Invitation Rate

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
phaedo5
Forum Newbie
Posts: 6
Joined: Tue May 20, 2008 4:42 pm

Invitation Rate

Post by phaedo5 »

I want to set up an action for a website user, but I want to be able to set a percentage of user participation.

For instance, let's say I want to have something happen to 20% of the users that come to my site, like a survey or something. I know how to set cookies back and forth, but I am lost as to how I could have this happen to a set percentage of users.

Any one able to help with that??
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: Invitation Rate

Post by jayshields »

There are many ways to do this. The simplest way I can think of is to have a number in a text file on your server be incremented everytime a user loads the page. Check that same number everytime a page is loaded too. The number % 5 will equal 0 for every fifth person that accesses your website. So you can trigger a survey or whatever.
Post Reply