iFrame a Link & Still Track Conversions
Saturday May 3, 2008 // Share on Facebook
@IamJustinM asked the other day
Is it even possible to track visitors and conversions when you have the landing page in an iframe??? Can’t figure it out….
I gave a quick answer, “at top of iframe page, write tracking data to db, then get unique id and use that as your sid w/ the network” but wanted to show it a bit more in detail. So I took 5 minutes I whipped up this quick script:
<?php
// http://yourdomain.com/iframe.php?cSource=google&q=my+keyword
mysql_connect(’server’, ‘username’, ‘password’);
mysql_select_db(‘databasename’);
$cTable = ‘iframetrack’;
/*
CREATE TABLE `iframetrack` (
`nID` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`cSource` VARCHAR( 20 ) NOT NULL ,
`cKeyword` VARCHAR( 200 ) NOT NULL ,
`cBrowser` VARCHAR( 200 ) NOT NULL ,
`nIP` VARCHAR( 16 ) NOT NULL ,
`tsDatetime` DATETIME NOT NULL
) ENGINE = MYISAM ;
*/
if (empty($_GET['q'])) {
list(, $cRefererQS) = explode(‘?’, $_SERVER['HTTP_REFERER'], 2);
parse_str($cRefererQS, $_RefererGET);
$_GET['q'] = $_RefererGET['q'];
} // ends if (empty($_GET['q']))
$cQuery = “insert into $cTable (cSource, cKeyword, cBrowser, nIP, tsDatetime) values (’” . mysql_real_escape_string(stripslashes($_GET['cSource'])) . “‘, ‘” . mysql_real_escape_string(stripslashes($_GET['q'])) . “‘, ‘” . mysql_real_escape_string(stripslashes($_SERVER['HTTP_USER_AGENT'])) . “‘, ‘” . mysql_real_escape_string(stripslashes($_SERVER['REMOTE_ADDR'])) . “‘, now())”;
mysql_query($cQuery);
$nID = mysql_insert_id();
$cAffLink = ‘http://www.cpaclicks.com/redirect.asp?a=2429&b=27673&d=0&l=0&o=’ . $nID . ‘&p=0′;
?><!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html lang=”UTF-8″>
<head>
<title>Title</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″ />
<meta http-equiv=”Content-Language” content=”UTF-8″ />
</head>
<body style=”padding:0px; margin:0px;”>
<iframe name=”mainsp” id=”mainsp” src=”<?= $cAffLink ?>” width=”100%” height=”100%” scrolling=”auto” frameborder=”0″>
<p><a href=”<?= $cAffLink ?>“>Click to continue.</a></p>
</iframe>
</body>
</html>
Now it’s probably not perfect, but it gives you a way to track this info. When you link to this iframe, set cSource to the source of the visitor (can be just the source, or source & ad number combined - whatever) and (optionally) set “q” to the keyword. If you omit this, it’ll look at “q” from the HTTP_REFERER, which is what most search engines use for the keyword field.
I’m not going to go into detail on how to change things - if you need help, just ask.
PS - Sorry about the funky quotes - WordPress is being “smart”. Find / replace to fix it.
This entry was posted on Saturday, May 3rd, 2008 at 3:35 pm and is filed under Affiliate Marketing, Uncategorized. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.


Join the Discussion