I have completed first phase of a simple, yet useful Newsletter System. When I demonstrated to the clients, they came up with a question if the newsletter being send was opened or not by the newsletter subscribers ? I then thought.. let see how its done. Then I came with this simple tracking trick, most of the spammers used to verify if the email address was valid or not.
The first thing I did was adding 1px by 1px image on the footer of the newsletter, whose source was set something like this http://subesh.com.np/newsletter/track.php?identitycode=CLIENTID_SENDEMAILID. Here CLIENTID = Your Clients ID and SENDEMAILID = Id of the Newsletter sent. Now, when the image is loaded while viewing the newsletter on the mail or say when the client reads the newsletter email. The track.php page is requested with identitycode as the GET parameter. And when you get the request from the mail to your server’s page, you can do anything you want. What I did was setting the mail_read column of the database field as 1. And echoed the source of the image file on the last line.
The code below is for the track.php.
<?php
$get=explode("_",$_GET['identitycode']);
$sendid=$get['0'];
$recid=$get['1'];
$query="INSERT INTO tbl_track SET mail_read='1' WHERE send_id='$sendid' and user_id='$recid'";
mysql_query($query);
echo "http://subesh.com.np/newsletter/images/transparent_1px.gif";
?>
Isn’t this the easiest idea anyone could ever come up with. Yeha! Thumbs up to me!!
You can do the same with ASP?
Yeha! Sure…
nice trick but never ever forget to sanitize the data before using them in a query…
yeha!… I have seen the function sanitize()…ummmm… yeha… joomla search component
I’ll throw you a bone here since I found your url in the Magento forum and you helped me out with the entity_id filter.
Using a *.php (or any script language) to track and then return an image is a definite no-no. Spam filters will pickup on this (web beacon) and slam you for it.
What you really want to do is use an http handler in a directory to catch *.gif/jpg calls and use the format something like _.gif. Then use the params in the name to tag the reader as opening a specific newsletter.
Honestly though… writing a newsletter delivery system is something best left to someone dedicated to the task ;o)
Hello,
I need to track whether email sent by me is being opened/read by the reciepient or not.
I am trying your above given script,but it doesn’t works.
my code is :
Html Mailer Content:
I have appended this code in the footer of html mailer file.
Action file code :
$email=$_REQUEST['email'];
$category=$_REQUEST['category'];
$rssel = mysql_query(”SELECT * FROM mytable WHERE CategoryId=’$category’ AND Email=’$email’”);
if(mysql_num_rows($rssel) == 0)
{
mysql_query(”INSERT INTO mytable(CategoryId,Email) VALUES(’$category’,'$email’)”);
}
echo “http://www.mydomain/images/calendar.gif”;
But when we execute the page it does not replaces source with following code
echo “http://www.mydomain/images/calendar.gif”;
Kindly Help!!
Thanks in advance…
Regards
Vikas
Did you put a 1px image code like this
[ img src="http://subesh.com.np/newsletter/track.php?identitycode=CLIENTID_SENDEMAILID" width=1px height=1px ]
The html code has not been shown