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
If you want to track ip and referrer using PHP, then use SimpleCoder’s advice.
If you want to track ip and referer using some 3rd party javascript tracking code (like Google Analytics or whatever), you can create a “landing” page with a “Refresh” header. Something like
Browser will first load this page, javascripts will execute, and then it will redirect to url specified in the header