Affiliate Tracking Script

Status
Not open for further replies.

cyberworkspace

Beat Me @ MyStockBet.com
Feb 2, 2007
392
5
0
as i started to do my first steps into the affiliate marketing game, i am coming towards my first need for a better tracking of my campaigns.

i use greenham's redirect script so far, for redirecting different adgroups to different azoogle subids, like e.g.:

adwords target-url
http://www.mydomain.com/linker.php?id=myadgroup1

where the linker.php script would then redirect to 404 Error

now, as my first campaigns are running, i realize how much more information i would love to get about the clicks i am receiving. those add-on's i would like to get for this script are:

- to write the called id, date and time into a text-file, once linker.php has been called
- to be able to rotate various affiliate-links, so that i can test, which offer of the same type gets the best ctr. e.g.

click #1 on adgroup1 triggers http://x.azjmp.com1/XYZ?sub=myadgroup1
click #2 on adgroup1 triggers http://x.azjmp.com2/XYZ?sub=myadgroup1
click #3 on adgroup1 triggers http://x.azjmp.com3/XYZ?sub=myadgroup1
and click #4 on adgroup1 triggers http://x.azjmp.com1/XYZ?sub=myadgroup1 again

can anyone extend the script below (copyright by greenham's) to add the functionality as described above? if you want to get paid to do the job, that is fine with me. however be aware that the result of your work should be made available to everyone here.

PHP:
<?php

$path = array(
  'adgroup1' => 'http://x.azjmp.com/XYZ?sub=azoogleadgroup1',
  'adgroup2' => 'http://x.azjmp.com/XYZ?sub=azoogleadgroup2'
   );

if (array_key_exists($_GET['id'], $path))
  header('Location: ' . $path[$_GET['id']]);

?>
if you see usefull stuff that should be added as well, please just say so. thanks!
 


oh please, don't let me suffer :)

i know, maybe i posted this in the wrong section, but still someone must know whether there are scripts available that do what i need. i got no problem to get this developed by someone at rent-a-coder but i thought someone might be interested to take the job here :)
 
PHP:
<?php

$path = array(
    'searchengines' => array('http://www.google.com','http://www.yahoo.com'),
    'favoritesites' => array('http://www.gay.com','http://www.tubgirl.com')
    );

if (array_key_exists($_GET['id'], $path))
{
    $sites = $path[$_GET['id']];
    $randKey = array_rand($sites);
    header('Location: ' . $sites[$randKey]);
}

?>
This should go to a random url for each id. As far as saving times of each click, I might add fuctionality to store info about each click to a MySQL database but I don't feel like it right this moment. :rasta:
 
PHP:
<?php

$path = array(
    'searchengines' => array('http://www.google.com','http://www.yahoo.com'),
    'favoritesites' => array('http://www.gay.com','http://www.tubgirl.com')
    );

if (array_key_exists($_GET['id'], $path))
{
    $sites = $path[$_GET['id']];
    $randKey = array_rand($sites);
    header('Location: ' . $sites[$randKey]);
}

?>
This should go to a random url for each id. As far as saving times of each click, I might add fuctionality to store info about each click to a MySQL database but I don't feel like it right this moment. :rasta:

thanks a lot for that :) that helps me a lot when it comes to split testing ads for the same product-type from different suppliers.

as for sql, that wouldn't be necessary. a simple .txt should do the trick, as i would crunch the numbers in excel anyways ;)

thanks!
 
MySQL shouldn't really be any more difficult so I'll probably do that because it should be faster than writing to a text file and easier if someone wants to add more features later. You can just export the contents of the database to something excel can read with phpMyAdmin.
 
thanks a lot for that :) that helps me a lot when it comes to split testing ads for the same product-type from different suppliers.

as for sql, that wouldn't be necessary. a simple .txt should do the trick, as i would crunch the numbers in excel anyways ;)

thanks!
It's just my personal opinion based on no knowledge of your operation and I mean this in the most constructive way possible, but don't start down this path. Invest the work to start storing your data in a granular, relational format in a database. Once you have it there you can always export it as a flatfile (csv) and import it into Excel, but when you start developing a marketing support system, you'll already have a ton of good data stored intelligently to help you run your operation.

Incidentally, I just wrote a blog article that's describing the theory and concepts behind what you're doing - it's here. Probably more than you're interested in reading at the moment, but it's good info and it roughly explains (using accounting as the focus) the larger point of storing your data relationally with respect to affiliate networks. A/B splits using a randomizer will get the job done right now, but once you're keeping track of your traffic intelligently (and I don't talk about this in the article) you can impose flow control structures on your pages to make a split based on all kinds of exacting and automated metrics. (That's for a future article, heh).
 
It's just my personal opinion based on no knowledge of your operation and I mean this in the most constructive way possible, but don't start down this path. Invest the work to start storing your data in a granular, relational format in a database. Once you have it there you can always export it as a flatfile (csv) and import it into Excel, but when you start developing a marketing support system, you'll already have a ton of good data stored intelligently to help you run your operation.

that's great advice, no question. in fact i intent to do this, but i was very much hoping to come across a commercial package that would deliver all of this to me. so, all the modifications which would be done to the script above would be an interim-solution. for now, i have a pretty good overview about my campaigns and keywords, as i am a bloody noob in this business and am just testing.

Incidentally, I just wrote a blog article that's describing the theory and concepts behind what you're doing - it's here. Probably more than you're interested in reading at the moment, but it's good info and it roughly explains (using accounting as the focus) the larger point of storing your data relationally with respect to affiliate networks. A/B splits using a randomizer will get the job done right now, but once you're keeping track of your traffic intelligently (and I don't talk about this in the article) you can impose flow control structures on your pages to make a split based on all kinds of exacting and automated metrics. (That's for a future article, heh).

that is indeed a great article! i have just crossread it and i will right now take my time to read it from the beginning to the end, as it exactly seems to discuss (and solve) the issues i had in mind during the last days: i want to own the keywords, independently from any particular affiliate campaign i am running them on. only this way i will be able to chose and switch my product suppliers at any given time for any reason without giving up the market share (= keywords).

last but not least: i am absolutely with you when it comes to storing and manipulating all data in a database. what i am wondering though: i haven't seen you referencing any 3rd party package either in your post. simply because there is none?
 
MySQL shouldn't really be any more difficult so I'll probably do that because it should be faster than writing to a text file and easier if someone wants to add more features later. You can just export the contents of the database to something excel can read with phpMyAdmin.

well, that is great then. fine, i am looking forward to see the final script :D
 
First of all, create the MySQL table:
Code:
CREATE TABLE `linkTracker_clicks` (
  `key` int(11) NOT NULL auto_increment,
  `adGroup` varchar(255) NOT NULL,
  `urlVisited` text NOT NULL,
  `ip` varchar(255) NOT NULL,
  `referer` text,
  `date` date NOT NULL default '0000-00-00',
  `time` time NOT NULL default '00:00:00',
  UNIQUE KEY `key` (`key`)
) TYPE=MyISAM;
Then here's the script:
PHP:
<?php

$mysqlHostname = "localhost";
$mysqlUsername = "username";
$mysqlPassword = "password";
$mysqlDatabaseName = "database_name";

$path = array(
    'searchengines' => array('http://www.google.com','http://www.yahoo.com'),
    'favoritesites' => array('http://www.gay.com','http://www.tubgirl.com')
    );

if (array_key_exists($_GET['id'], $path))
{
    $sites = $path[$_GET['id']];
    $randKey = array_rand($sites);
    header('Location: ' . $sites[$randKey]);

    $referer = $_SERVER['HTTP_REFERER'];
    $query = "INSERT INTO linkTracker_clicks (adGroup, urlVisited, ip, referer, date, time) VALUES('".$_GET['id']."', '".$sites[$randKey]."', '".$_SERVER['REMOTE_ADDR']."', '".$_SERVER['HTTP_REFERER']."', NOW(), NOW())";

    mysql_connect($mysqlHostname, $mysqlUsername, $mysqlPassword) or die(mysql_error());
    mysql_select_db($mysqlDatabaseName) or die(mysql_error());
    mysql_query($query) or die(mysql_error());
}

?>
It saves the ad group, url, ip, referer, date, time into the database for each click. I'm going to start using this with a few campaigns to see how it works.

This question is a bit late but have you looked around at free link tracking scripts like the ones here? Scroll down to get to the free ones. Hotscripts.com :: PHP :: Scripts and Programs :: Click Tracking

If there isn't something suitable to PPC somewhere maybe I'll make a more complete/useful script as I and many others could benefit from one.

That will be $500. :)
 
wow, that was fast :) thanks a lot!
i will try this one first thing tomorrow and test it.

admittedly, i have browsed hotscripts before, but obviously i failed to pick the right search terms. i will take a look at those ones available and maybe there is further stuff that can be merged. this is for sure just the starting point as one later needs much more fancy solutions, but as said, i am fine with magaging certain aspects by hand for the moment being :)

ah, yes. here is your money --> $500 :D

thanks a lot!
 
that's great advice, no question. in fact i intent to do this, but i was very much hoping to come across a commercial package that would deliver all of this to me. so, all the modifications which would be done to the script above would be an interim-solution. for now, i have a pretty good overview about my campaigns and keywords, as i am a bloody noob in this business and am just testing.

that is indeed a great article! i have just crossread it and i will right now take my time to read it from the beginning to the end, as it exactly seems to discuss (and solve) the issues i had in mind during the last days: i want to own the keywords, independently from any particular affiliate campaign i am running them on. only this way i will be able to chose and switch my product suppliers at any given time for any reason without giving up the market share (= keywords).

last but not least: i am absolutely with you when it comes to storing and manipulating all data in a database. what i am wondering though: i haven't seen you referencing any 3rd party package either in your post. simply because there is none?
Thanks and I understand where you're coming from. Making money is the driving force behind the business and technology should not handicap that, so of course that should come first. I just try to advise on best practices as early as I can because I've worked with so many companies that actually get addicted to bad practices and are then reticent to change (doing things right is always harder). I do wish you best of luck and of course there's nothing wrong with being messy until you've got enough extra resources to start paying attention to your infrastructure.

As for your last, I've never seen anything on the commercial market that can do what I want. I've built and/or architected systems that have, but they're so tailored to an individual company's needs and it's such a niche market that I don't think there's enough demand. That being said, I HAVE heard of link/stat packages out there that do a good job of tracking your links and representing the reporting data. I have no idea if these packages know how to true up with affiliate networks or if they can integrate with existing user databases, but I suspect not. I'm positive that there aren't any that know how to talk to an email solution, a PPC solution, an affiliate network, a landing page platform, an offer path management platform and other systems all at once.

Beyond that, there are the hosted solutions like Urchin/Google Analytics, CrazyEgg and others that each do a piece of the job but none of which do the entire job. I'm afraid to do that you have to do it yourself. Fortunately if you build it in from early on it's not hard. What's hard is building it in later when you've got sixty landing pages, twenty blogs, PPC campaigns on four providers and an email system all driving traffic to seven affiliate networks.

Good luck!
 
that script is working great, thanks a lot!

i digged myself into the code and extended it, so that i can now store the keywords for which the search was made. if anyone is interested, i can post that axtension here. i just don't want to make the postings here anymore complicated so that no one gets confused which version is the right one.

i am now really beginning to understand the significance of getting your stats right. to collect as much information as possible about your customers is really an absolute must.
 
that script is working great, thanks a lot!

i digged myself into the code and extended it, so that i can now store the keywords for which the search was made. if anyone is interested, i can post that axtension here. i just don't want to make the postings here anymore complicated so that no one gets confused which version is the right one.

i am now really beginning to understand the significance of getting your stats right. to collect as much information as possible about your customers is really an absolute must.

Yes, please post the extension of the code. I would be very interested.

Thanks.

Chris
 
Status
Not open for further replies.