Location redirect - is tracking possible ?

Posted by Gerald Ferreira on Stack Overflow See other posts from Stack Overflow or by Gerald Ferreira
Published on 2010-12-28T22:41:30Z Indexed on 2010/12/28 22:53 UTC
Read the original article Hit count: 301

Filed under:
|

Hi there, I was wondering if someone can help me, I have the following script that redirect users to an affiliate link when they click on a banner.

<?php
$targets = array(
'site1' => 'http://www.site1.com/',
'site2' => 'http://www.site2.com/',
'site3' => 'http://www.site3.com/',
'site4' => 'http://www.site4.com/', );
if (isset($targets[$_GET['id']])) {
header('Location: '.$targets[$_GET['id']]);
exit; } 
 ?>

Is it possible to track when a user hits the banner telling me the referer site as well as the ip address of the person clicking on the banner.

hmmmm something like pixel tracking?

I have tried to add an iframe that does the tracking but it creates an error

Hope it makes sense

Thanks!

This is more or less how I would have done it in asp

   <%

    var Command1 = Server.CreateObject ("ADODB.Command");
    Command1.ActiveConnection = MM_cs_stats_STRING;
    Command1.CommandText = "INSERT INTO stats.g_stats (g_stats_ip, g_stats_referer)  VALUES (?, ? ) ";
    Command1.Parameters.Append(Command1.CreateParameter("varg_stats_ip", 200, 1, 20, (String(Request.ServerVariables("REMOTE_ADDR")) != "undefined" && String(Request.ServerVariables("REMOTE_ADDR")) != "") ? String(Request.ServerVariables("REMOTE_ADDR")) : String(Command1__varg_stats_ip)));
    Command1.Parameters.Append(Command1.CreateParameter("varg_stats_referer", 200, 1, 255, (String(Request.ServerVariables("HTTP_REFERER")) != "undefined" && String(Request.ServerVariables("HTTP_REFERER")) != "") ? String(Request.ServerVariables("HTTP_REFERER")) : String(Command1__varg_stats_referer)));
    Command1.CommandType = 1;
    Command1.CommandTimeout = 0;
    Command1.Prepared = true;
    Command1.Execute();

    %>

I am not sure how to do it in php - unfortunately for me the hosting is only supporting php

so I am more or less clueless on how to do it in php

I was thinking if I can somehow call a picture I can do it with pixel tracking in anoter asp page, on another server.

Hope this makes better sense

© Stack Overflow or respective owner

Related posts about php

Related posts about JavaScript