Managing banner ad clickthroughs

Application ( 'ClickFromIP' )

Having created a new Application variable called 'ClickFromIP' that is initialized each day, now I just have to make some use of this to store the IP addresses of people who click my ads:

// ignore any IP addresses that have been used today
var sIP ='>' + Request.ServerVariables ( 'REMOTE_ADDR' ) + '<';
var sClickIPs = Application ( 'ClickFromIP' );
var bIgnoreClick = false;
// test if IP has clicked before
if ( -1 != sClickIPs.indexOf ( sIP ) )
{
    // they've clicked before, so ignore them
    bIgnoreClick = true;
}
else
{
    // this IP hasn't clicked before, so add to list
    Application.Lock ( );
    Application ( 'ClickFromIP' ) = Application ( 'ClickFromIP' ) + sIP;
    Application.Unlock ( );
}

First I get the IP address from the ServerVariables collection. Then I get the current ClickFromIP variable, and test if the current IP appears in the string using the String.indexOf method.

If it does, then I ignore the clickthrough (I still allow the clickthrough, just don't charge the client for it)

If it hasn't been used before I concatenate the IP to the string. This is why I prefixed it with a > character (on the first line) so that each IP address will be separated by this character in the string.

You might also like...

Comments

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“A computer lets you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila” - Mitch Ratcliffe