Page 1 of 1
Tracking of html emails
Posted: Mon Jun 13, 2005 1:18 pm
by voddie
Hi
I have a newsletter app running through php/mysql which has a sub/unsubscribe function and can deliver emails to the subscriber list in either html or straight text.
I want to expand my app so that I can track on the delivery/opened/links/campaign number/clicked thros etc of the email.
The tracking needs to be inserted into the database and be able to be queried for results/logs etc.
Im not too sure where to start looking for information, or even if I should be looking at javascript/php for the answer.
Can anyone point me in the right direction? ideas? links? articles?
Thanks in advance for any assistance offered.
Voddie
Posted: Mon Jun 13, 2005 1:40 pm
by shiznatix
sounds like you are a *shudder* SPAMMER! ah well i guess we are all sinners.
the best way to do the tracking of if the email was opened is to have a image that is 1px by 1px in the page and have it as a php like like
Code: Select all
<img src="e;www.site.com/index.php?email=the_email_this_is_sent_to@server.com"e;>
that way the person has to make a request to your server to get that information and then you can track the users IP address that opened the email and the email address that opened it and all of that happy stuff. then just store it in your db and run some querys to get that info out
Posted: Mon Jun 13, 2005 1:52 pm
by voddie
Hi Shiznatix
We all have to make a living, but id dont like to think of spamming anyone, least of all my newsletter subscribers.
I came across that way of tracking, quite crude really, but wanted something a little more effective like what time they opened, whether it was deleted, what links they clicked so as to make my newsletter more receptive of their needs.
I see thousands of companies offering this as a professional service, so the coding logic behind must be available, if only in description.
I searched under different terms to no avail, I just want to know how they do it using php and maybe javascript.
Cheers anyway
Voddie
Posted: Mon Jun 13, 2005 5:12 pm
by shiznatix
ya i understand but i gave you a perfect way of how to do it. you make a image like this
Code: Select all
<img src="e;www.site.com/index.php?email=the_email_this_is_sent_to@server.com"e; height="e;1"e; width="e;1"e;>
then on site.com/index.php
Code: Select all
if (isset($_GET['email']))
{
$ip = $_SERVER["REMOTE_ADDR"];
$email_address_that_opened_email = $_GET['email'];
$query = '
INSERT INTO
table_name_here
(ip, time, email)
VALUES
("'.$ip.'", now(), "'.$email_address_that_opened_email.'")
';
$do_query = mysql_query($query) or die(mysql_error().__LINE__);
}
//then if you want to query from the table
$query = '
SELECT
*
FROM
table_name_here
WHERE
email="'.$some_email_address.'"
';
$do_query = mysql_query($query) or die(mysql_error().__LINE__);
while ($info = mysql_fetch_assoc($do_query))
{
echo 'IP Address: '.$info['email'].'<br>';
echo 'Time: '.$info['time'].'<br>';
echo 'Email: '.$info['email'];
}
i dont have time to write you a entire script but you can do the same style of stuff for the links the clicked on (if it is a link to a page on your server) and everything else. so do you get the idea?
Posted: Tue Jun 14, 2005 8:40 am
by voddie
Thanks for that, my coding isnt that good yet, but I get a sense of what your saying.
What i dont understand is what you mean by the links, how do i do that? put some code along with the link?
Thanks in advance
Voddie
Posted: Tue Jun 14, 2005 8:57 am
by JayBird
shiznatix wrote:sounds like you are a *shudder* SPAMMER! ah well i guess we are all sinners.
the best way to do the tracking of if the email was opened is to have a image that is 1px by 1px in the page and have it as a php like like
Code: Select all
<img src="e;www.site.com/index.php?email=the_email_this_is_sent_to@server.com"e;>
that way the person has to make a request to your server to get that information and then you can track the users IP address that opened the email and the email address that opened it and all of that happy stuff. then just store it in your db and run some querys to get that info out
This method WILL NOT be 100% accurate...a lot of email programs DO NOT automatically download additional email content i.e. images unless you tell it to do so.