Beacons, Web Bugs, Pixels...oh my.

Status
Not open for further replies.

Mike

New member
Jun 27, 2006
6,777
116
0
51
On the firing line
This is driving me bonkers. I'm trying to create a simple pixel to place on an advertisers page so I can track conversions.

Here's what I've got so far:
  • .htaccess setup to redirect /images/pixel.gif to my php script
  • PHP script that is supposed to capture certain information and write it to a text file
  • text file to keep the data
And what works:
  • .htaccess is doing it's job
  • php script is writing to the file
What doesn't work:
  • capturing ANY information from the page.
I'm testing this on my sites. So, I placed the pixel on Site A
Code:
<img src="http://www.SiteB.com/images/pixel.gif" alt=" " />
When you load SiteA's page, it loads that "image" which causes .htaccess to redirect to the PHP script which then does it's thing.

Here's the PHP script I wrote:
Code:
<?php
$qs = $_SERVER['QUERY_STRING'];

$myFile = "test.txt";
$fh = fopen($myFile, 'a');

$stringData = "$qs\n\n";
fwrite($fh, $stringData);

fclose($fh);
?>
So, it's writing the new lines to the file, but not the Query String.

If the image is on a page with any kind of query string, shouldn't it pick that up?

Is this due to the use of $_SERVER instead of something else?

Also, if someone could point me to a good web bug resource with script samples, that would be fan-fucking-tastic.
 


Use the PHP script as your image src. I'm betting the details are getting stripped in the redirect from an image to your script and there isn't really a need for the extra step.

Code:
<img src="http://www.siteb.com/pixeltracker.php">

Then in your PHP script you can either do a redirect to a real image, output one, or don't worry about it if the image won't be seen anyways (1x1).

Edit: Also you can't get the querystring of the page that way, it will just give the querystring passed in the img src (which is none here). Use $_SERVER['HTTP_REFERER'] and it will give you the URL of the parent page displaying the image.
 
Status
Not open for further replies.