-1

I have a question. I would like to add rotating links inside my email signature to track results on my site. I can make these dynamic tracking urls on google as you may know but I would like to rotate them inside my email signature to see which text draws the most conversions or returning visitors.

Is this possible?

I found this for instance:

$mybanners[1] = '<a href="http://www.affiliate1.com"><img src="banner1.jpg"></a>';
$mybanners[2] = '<a href="http://www.affiliate1.com"><img src="banner1.jpg"></a>';

$id = rand(1,2);

echo $mybanners[$id];

But when I look into my windows live mail I can only upload html files.

Does someone know how to do this?

gen_Eric
  • 223,194
  • 41
  • 299
  • 337

1 Answers1

2

You can't provide PHP scripts in a mail, since it is a server-side language and it will be opened by a mail client. Even Javascript is very often blocked for security reason.

What you can do is make a "fake" image which will be in fact generate by a PHP script. YOu can find inspiration by looking to script made for forum avatar rotation. The idea is to generate an image, which will be displayed to the client but, in the same time, save some data about the user who requests the image if you want:

<?php
// Save whatever you want about the user
file_put_content("log/user.txt", $_SERVER['HTTP_REFERER']);

// Render a valid PNG image
header('Content-Type: image/png');    
readfile("/path/to/banner.png");
?>

This script should be used as a standard image (with, if you want, a nice URL rewrite to make a .png link):

<img src="http://www.example.com/my_super_banner.php" />

where my_super_banner.php is the script described before.

Maxime Lorant
  • 34,607
  • 19
  • 87
  • 97
  • You *can* do ``. As long as you have that `header` line, that will work. Rewriting the URLs looks nice, but if you don't want to, you don't need to. – gen_Eric Jun 02 '14 at 16:27
  • @RocketHazmat Yes, yes... I prefer to have a `.png` extension in this case, but it is another subject, so I have edited it, you are right. – Maxime Lorant Jun 02 '14 at 16:28
  • Hey guys. I'm a coding noob. If I want to let two links rotate. Can you please show me the entire code? – user3700083 Jun 02 '14 at 19:24
  • [Stack Overflow is not a "code this for me please" service](http://stackoverflow.com/help/how-to-ask), sorry. – Maxime Lorant Jun 02 '14 at 19:50