Author Topic: Track how many times an HTML message was opened  (Read 38703 times)

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
Track how many times an HTML message was opened
« on: May 02, 2004, 04:15:39 pm »
I thought I'd start the forum off with an example -

This script can be used to track how many times HTML messages were opened (until the feature is implemented into ListMail).

Instructions:

Copy and paste the code below into a new text file.

Code: [Select]

<?phpsession_start();/* to install databases, run the following query in  PhpMyAdminCREATE TABLE `track` (`autoid` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,`uid` TINYTEXT NOT NULL ,`msgid` TINYTEXT NOT NULL ,`stamp` TIMESTAMP NOT NULL);*/// CONFIG// admin password (for viewing stats)$apw = 'admin';// track database access info$t_host = 'localhost';$t_user = 'USER';$t_pass = 'PASS';$db = 'DATABASE';$table = 'track';// ListMail database access info$lm_host = 'localhost';$lm_user = 'USER';$lm_pass = 'PASS';$lm_db = 'DATABASE';// leave this$lm_table = 'lm_users';// END CONFIG// initialize vars + mysql// less warnings under windowserror_reporting (E_ALL ^ E_NOTICE);// get data$mid = $_GET['m'];$uid = $_GET['u'];$msg = $_GET['msg'];$admin = $_GET['admin'];$login = $_POST['login'];$logout = $_GET['logout'];$pw = $_POST['pw'];$reset = $_GET['reset'];$PHP_SELF = $_SERVER['PHP_SELF'];// magic quotes in post/get dataif(ini_get('magic_quotes_gpc')>0) $gpc = 1; else $gpc = '';if($gpc){	if($mid) $mid = stripslashes($mid);	if($uid) $uid = stripslashes($uid);	if($pw) $pw = stripslashes($pw);	if($msg) $msg = stripslashes($msg);}$link = mysql_connect($t_host,$t_user,$t_pass);mysql_select_db($db,$link);$link2 = mysql_connect($lm_host,$lm_user,$lm_pass);// define headerfunction mainheader($title,$nohead=''){	echo "<html><head><title>$title</title><style type=text/css rel=stylesheet><!--	.bighead { font: bold 12pt helvetica; color: #000000; }	.tbl1 { border: 1px solid #000000; padding: 0px 2px 1px 2px; }	.head_bg1 {		background: navy;		border-bottom: 1px solid #000000; }	}	.head_txt1 { font: 9pt helvetica; color: white; }	.head_txt2 { font: 8pt helvetica; color: #000000 }	.txt1 { font: 9pt helvetica;}	.txt2 { font: 8pt helvetica }	.link1,.link1:visited { font: 9pt helvetica; color: #000000 }	.link1:hover { text-decoration: underline; }	.viewhead { background: #eeeeee }	.button {		border: 1px solid #000000;		font: 8pt helvetica;		width: 120px;		background: #eeeeee;		margin-top: 3px;	}	.txtbox {		font: 8pt helvetica;		border: 1px solid #000000;	}}--></style></head><body>\n";if(!$nohead){   $width=' width=120';	echo "<table width=100% border=0 cellspacing=0 cellpadding=0><tr><td><span class=bighead>Message Views</span><br></td><td align=right><a class=link1 href=$PHP_SELF?logout=1>Logout</a><br></td></tr></table>\n";}echo "<table width=100% border=0 cellspacing=0 cellpadding=0>\n <tr>\n  <td valign=top$width>\n";}function msgheader(){	echo "<table width=100% class=tbl1 border=0 cellspacing=0 cellpadding=0> <tr class=head_bg1>  <td><span class=head_txt1>Messages</span><br></td> </tr> <tr>  <td>\n";}function viewheader(){	global $db; global $link; global $msg; global $table;	mysql_select_db($db,$link);	$rows = mysql_query("select autoid from $table where msgid = '$msg' group by uid",$link);	$nviews = @mysql_num_rows($rows);	$rows = mysql_query("select autoid from $table where msgid = '$msg'",$link);	$tviews = @mysql_num_rows($rows);	echo "<table width=100% class=tbl1 border=0 cellspacing=0 cellpadding=0> <tr class=head_bg1>  <td colspan=4>   <table width=100% border=0 cellspacing=0 cellpadding=0>    <tr>     <td><span class=head_txt1>Views</span><br></td>     <td align=right><span class=head_txt1>$tviews Total Views, $nviews Unique Users</span></td>    </tr>   </table>  </td> </tr> <tr class=viewhead>  <td>\n";}function viewfooter(){  echo "</table>\n";}function msgfooter(){	global $msg;	echo "  </td>\n </tr>\n </table>\n";	if($msg) echo "<input class=button type=button value=\"Reset This Message\" onclick=\"window.location='$PHP_SELF?reset=this&msg=$msg'\"><br>\n";   echo "<input class=button type=button value=\"Reset All Messages\" onclick=\"window.location='$PHP_SELF?reset=all'\"><br>";}function mainfooter(){	echo "  </td>\n </tr>\n</table></body>\n</html>\n";}// login / logout / resetif($uid && $mid) $_SESSION['loggedin']='';if($logout){ mainheader('Logged out','nohead'); $_SESSION['loggedin']=''; echo "<span class=txt1>Logged out. <a class=link1 href=$PHP_SELF?admin=1>Re-login?</a><br></span>"; mainfooter(); exit; }if($login){	if($pw==$apw){		$_SESSION['loggedin']='123';		$admin=1;	} else sleep(5);}if ($_SESSION['loggedin']=='123') $admin = 1;// begin main scriptif($reset=='all'){	@mysql_query("delete from $table where 1");}if($reset=='this'){	@mysql_query("delete from $table where msgid = '$msg'");}// track the hit if we're not adminif($_SESSION['loggedin']<>'123' && !$admin){	// only continue if msgid and uid from LM	if($mid && $uid){		// track the hit		$uid = addslashes($uid);		$mid = addslashes($mid);		mysql_query("insert into $table (uid,msgid) values('$uid','$mid')",$link);		header("Content-type: image/gif");		readfile('./1.gif');	}} else {	if($admin && $_SESSION['loggedin']=='123'){		// if admin show result pages		mainheader('Tracked Messages');		$rows = mysql_query("select msgid from $table where 1 group by msgid order by msgid",$link);		msgheader();		if(@mysql_num_rows($rows)>0){			while(list($mid)=mysql_fetch_row($rows)){				$mid = addslashes($mid);				$row = mysql_query("select autoid from $table where msgid = '$mid'",$link);				$nviews = @mysql_num_rows($row);				$mid = stripslashes($mid);				echo "<a class=link1 href=$PHP_SELF?msg=".urlencode($mid).">$mid</a> <span class=txt1>($nviews views)</span><br>";			}			msgfooter();			if($msg){				echo "  </td>\n  <td width=10>&</td>\n  <td valign=top>\n";				viewheader();				$rows = mysql_query("select autoid,uid,msgid,stamp from $table where msgid = '$msg'",$link);				if(@mysql_num_rows($rows)>0){					echo "<span class=head_txt2>Name</span></td><td><span class=head_txt2>Email</span></td><td><span class=head_txt2>Date & Time</span></td> </tr>\n";					while(list($id,$uid,$mid,$stamp)=mysql_fetch_row($rows)){						$stamp = substr($stamp,0,4).'-'.substr($stamp,4,2).'-'.substr($stamp,6,2).' '.substr($stamp,8,2).':'.substr($stamp,10,2).':'.substr($stamp,12,2);						// get user data from ListMail						mysql_select_db($lm_db,$link2);						$urow = mysql_query("select list,email,fname,lname from $lm_table where uid = '$uid'",$link2);						mysql_select_db($lm_db,$link2);						if(@mysql_num_rows($urow)>0){							list($list,$em,$fn,$ln)=mysql_fetch_row($urow);						echo " <tr>\n  <td><span class=txt1>$fn $ln</span><br></td>\n  <td><span class=txt1>$em</span><br></td>\n  <td><span class=txt1>$stamp</span><br>  </td>\n </tr>\n";						} else {							echo "<tr><td colspan=4><span class=txt1>User not found in ListMail</span><br></td></tr>";						}					}				} else {				echo "<span class=txt1>No views for this message</span><br>\n  </td> \n</tr>\n";				}				viewfooter();				// <a class=link1 href=#			}		} else {			echo "<span class=txt1>No tracked messages.</span><br>";			msgfooter();		}		mainfooter();	} else {		if($admin && $_SESSION['loggedin']<>'123'){			mainheader('Login','nohead');			echo "<form name=f1 method=post><input type=hidden name=login value=1><span class=txt1>Password: </span><input type=text class=txtbox name=pw><br><input type=button class=button value=\"Login\"></form><script language=\"javascript\"><!--f1.pw.focus();--></script>\n";			mainfooter();		}	}}@mysql_close($link);?>



At the top of the file set a password and enter your MySQL access information.

Save the modified code as track.php and upload the file to your ListMail directory.

Create the database table by running the following query with PhpMyAdmin:

CREATE TABLE `track` (
`autoid` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`uid` TINYTEXT NOT NULL ,
`msgid` TINYTEXT NOT NULL ,
`stamp` TIMESTAMP NOT NULL
)

Set up a message code in ListMail, either Global or for the list(s) you want to use this on, named !uid.  Make this code of the type "User’s Unique ID".

To track a message, enter the following into any HTML email:

<img src=./track.php?u=!uid&m=my_message>

Replace “my_message” with a descriptive title for the current message (no spaces or funny characters).  This value is used in the tracking script to distinguish between emails.

To login and view tracked hits, browse to http://yoursite.com/mail/track.php?admin=1 and enter your admin password.

I should have this in the program very soon..
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting

shab

  • Posts: 12
    • View Profile
Track how many times an HTML message was opened
« Reply #1 on: May 02, 2004, 08:09:20 pm »
Nice one Dean, it looks like an open-rate script to me and I believe this is one of the most important feature when tracking ads. When will this be integrated into Listmail? If its not too long to implement this maybe I could just wait until the next release.
Submit Your Articles Now...
http://www.365articles.com

benjamin

  • Posts: 2
    • View Profile
Track how many times an HTML message was opened
« Reply #2 on: May 02, 2004, 11:08:11 pm »
Yeah,

that would be great..

BGSWebDesign

  • Posts: 625
    • View Profile
    • http://www.bgswebdesign.com
looks great, but... img tags can cause blocked emails...
« Reply #3 on: May 03, 2004, 04:35:31 pm »
Hi,

That script looks fabulous!  Here's a few questions I would have.  

#1.) I've heard that having <img> tags anywhere (even in HTML email) can cause that email to be flagged as UCE and get blocked, especially at AOL?

#2.) How can I include such a tag in a plain text Email, without having the <img> tag, is it possible?

#3.) I like the concept here, now you know the next part... provide a way to ONLY Email users that are in your User Database (for the list you are Emailing) that ALSO appear in the Tracking Database, in other words provide a way to Send a Mailing, and then give a checkbox like 'only Email previous clicked Users (for xx tracking ID)' that would Email only those who had clicked on a specific tracking link, that also appear in the User Database for the list!  Awesome, is it possible?
Thanks,
-Brett
http://www.bgswebdesign.com/Contact-Us.php

*** I do custom List Mail Pro installations ***
Contact me through my website (above)

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
Track how many times an HTML message was opened
« Reply #4 on: May 03, 2004, 04:51:29 pm »
[1]  I, too, have heard that having an image tag can cause your message(s) to bounce from AOL.  I believe this is because spammers use image tags to automatically tell them if a certain user is reading the email sent to them.  This harms all legitimate attempts to track HTML email.

[2] I do not know of a way to include automated tracking in text-only email.  I am pretty sure that this is not possible.

[3] The ability to email people who have clicked or viewed a message may be able to be worked into the upcoming rule-based sending feature.  However, it will not make it into the very next release, as the tracking features currently in ListMail still need to be greatly improved.

I expect to have simple HTML open-tracking as an option in ListMail very soon - perhaps even for the next release along with the Sent Messages page.
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting

Pavel

  • Posts: 14
    • View Profile
Track how many times an HTML message was opened
« Reply #5 on: May 17, 2004, 06:07:18 am »
Can we please spam-filters by replacing <img src=./track.php?u=!uid&m=my_message> with other tag of java script or other non-image object?
Pavel Lenshin
NeoProfit Circle

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
Track how many times an HTML message was opened
« Reply #6 on: May 17, 2004, 10:37:06 am »
I don't know if it would be possible to bypass spam/remote HTML image filters by using JavaScript or another HTML element.  I'm pretty sure that most email clients will not run JavaScript or other complex HTML.

Perhaps there is a way - I haven't looked very hard for an alternative.  I'll make a note of this and put some more time into it.

If you come up with anything new, post it here.
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting

BGSWebDesign

  • Posts: 625
    • View Profile
    • http://www.bgswebdesign.com
not that I know of...
« Reply #7 on: May 17, 2004, 12:26:19 pm »
Hi,

Regarding using another method.  I've been in business on the internet for 7 years.  The amount of email actually delivered these days is ridiculously low, I used to send HTML email but will not send it any more as I found my open rates and click rates drop considerably.

There is no method that I know of for replacing an image tag in html to get it past the filters, anything like javascript or other tag will also be flagged as spam!  

You'll also notice that most (if not all) famous internet marketers are known for sending plain text emails, now you know why.  I personally wrote to one and he said he had never sent an html email in his life, and this guy probably makes a six figure income.

Good luck in your search, if you do find something please post your results and success rates (open/click rates) here so we can see what it was, I'd sure be interested.
Thanks,
-Brett
http://www.bgswebdesign.com/Contact-Us.php

*** I do custom List Mail Pro installations ***
Contact me through my website (above)

valuehosted

  • Posts: 40
    • View Profile
    • http://www.phpreviews.com
Track how many times an HTML message was opened
« Reply #8 on: May 17, 2004, 12:51:14 pm »
open/read rates for something people have subscribed to has got to be pretty decent.

--Tone

BGSWebDesign

  • Posts: 625
    • View Profile
    • http://www.bgswebdesign.com
Track how many times an HTML message was opened
« Reply #9 on: May 17, 2004, 07:43:05 pm »
Hi,

Quote from: "valuehosted"
open/read rates for something people have subscribed to has got to be pretty decent.


Not really!  Try it you'll soon find out.  The churn rate for Email addresses is probably down to a month or so.  Even something people subscribe to is hard to get into their inbox, and even harder to open.... believe me, I'm talking from experience, if you know different post your open/click rates, I'd sure be curious.

The last thing you need is something that makes it even harder to get in their inbox, like html email.  Last I heard AOL was banning almost anything that had clickable links, and especially email with images, it's an option on their new spam filter....  good luck!  With 20-30% of the email addresses coming from AOL you'll really hurt your open/click rates by using html email.
Thanks,
-Brett
http://www.bgswebdesign.com/Contact-Us.php

*** I do custom List Mail Pro installations ***
Contact me through my website (above)

James Mason

  • Posts: 3
    • View Profile
Getting Past the Filters
« Reply #10 on: May 21, 2004, 12:25:28 am »
How about encrypting the html?

It works to get java into an eBay ad.

BGSWebDesign

  • Posts: 625
    • View Profile
    • http://www.bgswebdesign.com
Re: Getting Past the Filters
« Reply #11 on: May 21, 2004, 09:54:44 pm »
Hi Bret,

Quote from: "bretminkler"
How about encrypting the html?
It works to get java into an eBay ad.


That sounds like an interesting concept.  Please tell me how you encrypt it?  

I don't believe it will work though, as I believe that any SPAM filter would read the encrypted text and know that it is NOT plain text, I'm sure they probably look for real words and sentences, and throw out anything that looks like it's not true text, but maybe not if you can use it to get through Ebay???  

Please tell us the technique and the software/scripts you use to do the encrypting, point to an example if possible....
Thanks,
-Brett
http://www.bgswebdesign.com/Contact-Us.php

*** I do custom List Mail Pro installations ***
Contact me through my website (above)

clarksco

  • Posts: 7
    • View Profile
Track.php stopped working
« Reply #12 on: September 13, 2004, 06:21:30 pm »
Everything was going well.  Now when I load the page track.php?admin=1, enter my admin password and click login, nothing happens.  I verified that my password was correct.  I copied and pasted the code into tracks.php again, set the parameters and uploaded the change.  It still does nothing when I log in.  What do you think I am missing?
--Scott

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
Track how many times an HTML message was opened
« Reply #13 on: September 14, 2004, 07:37:21 am »
It's really hard to tell what's wrong.  Do you know how to manually confirm that your database contains the table used by the script?  You might also want to re-create the track.php file, re-entering your MySQL info.
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting

clarksco

  • Posts: 7
    • View Profile
Track.php stopped working for me.
« Reply #14 on: September 14, 2004, 12:20:30 pm »
Quote from: "DW"
It's really hard to tell what's wrong.  Do you know how to manually confirm that your database contains the table used by the script?
Yes.

Quote from: "DW"
You might also want to re-create the track.php file, re-entering your MySQL info.
I just did that and I am getting the same result.

Is there a debug version or a way to add an alert after clicking Login that shows the steps and which is failing?

FYI, the emails are being tracked and the hits are being written to the track table.
--Scott