Tracking your ad referer

Okay, so from time to time not even coders from advertising networks, mostly upstarting, niche networks don’t know how to code (seems like everyone is a programmer now).

I started noticing these horrible conversion rates and I started wondering. Are bots clicking my ads? Hmm, no. Are other people clicking my ads just for fun? Probably.

So I thought: Ric, just check where those clicks come from!

This is how you do it:

First, we need 2 files. A mysqlconnect.php and a index.php file.

The content of your mysqlconnect.php comes here

<?php

$mysqlhost=”host”; // MySQL-Host
$mysqluser=”user”; // MySQL-User
$mysqlpwd=”pw”; // Password
$mysqldb=”db”; // Database

$connection=mysql_connect($mysqlhost, $mysqluser, $mysqlpwd) or die(”Verbindungsversuch fehlgeschlagen”);

mysql_select_db($mysqldb, $connection) or die(”Couldnt connect to db server.”);

?>

The content of your index.php (redirect file)

<?php

$ref = mysql_real_escape_string($_SERVER['HTTP_REFERRER']); // escape sql, get refererrequire(”mysqlconnect.php”);// Include DB details

$sql = “INSERT INTO referer
(ref)
VALUES
(’”. $ref .”‘)”;// Insert referer into DB

mysql_query($sql) OR die(mysql_error());

// Redirect
Header( “HTTP/1.1 301 Moved Permanently” );
Header( “Location: http://www.your.offer.com/” );
?>

This is your SQL code. Execute it on your database.

CREATE TABLE IF NOT EXISTS `referer` (
`id` int(11) NOT NULL auto_increment,
`ref` varchar(1024) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=22 ;

This is not the best code for this kind of script.

But damn, I made this in 30 seconds. And hey, after all, it’s free. So feel free to post a better SQL or code for it in the comments :-)

Why am I publishing this
Many of us are using a network who we all know to advertise on social app’s. I was guessing that they were sending me clicks that did not really come from my ads.

Resumed: I was paying for clicks on ads who were set up by other advertisers. But getting those completely untargeted visitors sent to my page.

So what happened?

  1. User clicked on some ad (Ringtones blah blah blah)
  2. I got billed 1 click for a completely different ad (Dating here blah blah blah)
  3. User got redirected to my dating landing page

Okay, so I paid 15 cents for a worthless user. What a great feature.

How does that reflect in my earnings? You could guess: 137 clicks, no conversions. While other people are converting at 6:1, 5:1.

How do you track this?
Now you know :-)

advertiser network is

Share and Enjoy:
  • Digg
  • Sphinn
  • Facebook
  • del.icio.us
  • Mixx
  • Google
  • YahooMyWeb

 

4 Comments

  1. notsid

    Posted May 27, 2008 at 1:28 pm

    http://imgs.xkcd.com/comics/exploits_of_a_mom.png

  2. notsid

    Posted May 27, 2008 at 1:29 pm

    should be something more like this –

    $ref = mysql_real_escape_string($_SERVER['HTTP_REFERER']); // Get referer

  3. Posted May 27, 2008 at 1:43 pm

    thanks a lot! :) edited

  4. Posted August 11, 2008 at 6:22 am

    I am about to do this to monitor my click through rates

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*