external iframe, track exit link

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
LinuxMaster
Forum Newbie
Posts: 5
Joined: Tue Jun 27, 2006 10:11 am

external iframe, track exit link

Post by LinuxMaster »

I want to put an external page(one that I do not control) into an iframe. I then want to track what link they used to leave that website. Please advise. I have been researching but I am stuck now.

Code: Select all

whatever.html, just use a link like the following:

<a href="you.php?param=http://yo.com">Go</a>

And in yo.php, do something like:

$link = $_GET['param'];

// assume database connection
$dbh=mysql_connect ("localhost", "<un>", "<pwd>");

mysql_select_db ("<database>");
$query = "insert into sample (idx,link) values('','$link')";
$result = mysql_query($query);

header("Location: $link");
Will something like this work? What would you do if you wanted to mask the visible "extended URLs"?
User avatar
aerodromoi
Forum Contributor
Posts: 230
Joined: Sun May 07, 2006 5:21 am

Re: external iframe, track exit link

Post by aerodromoi »

LinuxMaster wrote:I want to put an external page(one that I do not control) into an iframe. I then want to track what link they used to leave that website. Please advise. I have been researching but I am stuck now.

Code: Select all

whatever.html, just use a link like the following:

<a href="you.php?param=http://yo.com">Go</a>

And in yo.php, do something like:

$link = $_GET['param'];

// assume database connection
$dbh=mysql_connect ("localhost", "<un>", "<pwd>");

mysql_select_db ("<database>");
$query = "insert into sample (idx,link) values('','$link')";
$result = mysql_query($query);

header("Location: $link");
Will something like this work? What would you do if you wanted to mask the visible "extended URLs"?
php:
Just to explain the principle: Once a user's got an html link displayed in his/her browser, it's out of your reach...
Of course, if you're able to modify the html the user gets, you can implement a redirection script in order to determine which links are most favoured by users. But as this is an external page...

javascript:
You'd need to access the iframe using a javascript function and rewrite the links so that they point to a redirection script on your server...

Please correct me if I'm wrong, but what do you need that for? :roll: :? :?
LinuxMaster
Forum Newbie
Posts: 5
Joined: Tue Jun 27, 2006 10:11 am

Post by LinuxMaster »

Random websites will be opened in an iframe. Each of those sites uses Google Adsense. I need to track if they clicked one of the Adsense links or if they atleast left the page via a google.com subpage. Adsense are actually in their own iframe, so depending on the method of my tracking, I might need to track within two iframes.

ughh.....
Post Reply