Email marketing statistics implementation - php

I will soon be tasked with making an email campaign manager, and part of it will be a statistics screen that will show how many emails were delivered successfully, how many were not, and how many people actually opened the email.
The main thing I can't get my head around is how to code the part that deals with people opening the email.
I know you could probably do it with a 1x1 white pixel, and then perhaps somehow have the server detect that it was loaded based on the image file name and trigger a script from that. But not all email clients have images enabled and in some cases they are disabled completely etc. I also think this method is quite dated?
I would like to know how the big players do this like Cheetah Mail etc.
What is the best way to do this using PHP/MySQL?
Thanks for your reply.
These are opted in subscribers and there will be afew links in the body of the email that will go to certain places on our websites. Tracking of those is easy because the link will have a string appended to it which will make it easy to detect if they visit the site from an email.
If whitepixel is the way to go at the moment, how do I go about linking the loading of that pixel to a script that is triggered on my server?

Firstly, I'd suggest using an off-the-shelf solution for this, rather than building your own - it's a complicated field, and others have already solved the problems.
As for the specific question, you can create an image tag in each mail along the following lines:
<img src="http://myserver.com/images/transparent.php?emailID=$IDofCurrentCampaign&uid=$emailAddressOfRecipient">
When this image is requested, the query string means it won't be cached, and your php script can store the campaign and email address in a database; you then need to respond with an image mime type, and send back a transparent gif.

Well most people do not like being tracked like that and thus will not load your pixel automatically.
Still, the white pixel "beacon" is the best method at the moment.
You could of course ask your viewers to click a link, but that will also require action from the receiver and will not give you the real number of people that opened the email.

Related

Override Gmail Image Cache (or set a short time limit) for time-sensitive images

We run a popular online marketplace and am experiencing issues with Google's new "Image Cache" service. We publish alerts via email with an image that tells the viewer whether the alert is still valid. If it is, its green and "Available". If its not, its grey and "Unavailable".
The problem we are having is that, when the recipient opens the email, Google fetches the image. It is usually "Available" right then, as it is usually opened very quickly after being sent.
However, when they open the email a second time, it shows "Available". They click the link, thinking they can still claim and take ownership of the alert, but find that is is actually no longer available. We are getting emails and bug reports of it being broken, but its actually a by-product of Google's new Caching service.
Everything worked before, and it still continues to work in other emails, like Outlook.com and Yahoo!. We send expiration headers and a "no-cache" header (which is why the other emails work) but cant seem to have Google check for a change.
Any ideas? Were really scratching our heads with this one. And we don't even know who at Google to talk to about this!
In short: no, it's not possible. You'd have to change the image url, which - of course - does not work in an email that has been sent. Don't bother asking someone at Gmail - they won't hear you. It also doesn't help your users to turn off the new "Always display external images" setting, because Gmail would still check and cache the graphics. So by now, marketers will have to live with not beeing able to use dynamic realtime images like countdowns, timers, or a product status in Gmail reliably.

Controlling Access for Trial Subscription

I've been tasked to build a system that allows someone in our company to send out an email with a link to a pdf file that will be kept on our webserver. The recipient can follow the link to view a newsletter we normally sell. The idea is we do this for three months, then see if they'd like to continue and pay for the full subscription.
I've got the registration portion built, but I'm trying to find the best solution for sending the email. Here's what I've thought of, but am interested if anyone else has something better..
1) When emailing, generate a generic code that gets appended to the URL. The use would follow the url, and it would check our DB for "ok" entries and pass/fail them access. This seems ok, but a link could be passed around or even loaded to a public site where anyone could access.
2) To extend the above, I thought maybe I'd have a "one time click" kind of thing where once I know the link was clicked, it could expire, so any subsequent clicks fail. The downside is if they click to view and close their window, they're done. Likewise, if they click and their computer crashes before download completes, they'd be locked out as well. I don't know if there's a way (in PHP for me) to confirm a file download has completed...
3) I could put the files in a directory like /trials/201009/r#nDomstr1n6.pdf where the file is uploaded and the name for the link is random so it would be hard to guess. Then I could use .htaccess to protect each month's folder with a different password. This could get tedious and would be annoying for users most likely.
We don't want to force them to manage their own passwords b/c having to login and remember yet another account may discourage participation.
Thanks for any ideas or pointers.
D.
I'd say do it with a random code for authentication per email address, and expire that after 5 days. If you limit access to the ip that first hit the url hash, that could work too but could iconvenience legitimate users/customers.
In any case make it easy for legitimate users to request a new authentication code if needed. That way even if any of your limitations inconvenience one of your potential customers, they will not be as ticked off about it.
Finally, consider that if they like the pdf and want to share it, they will probably just share the pdf itself right away and not bother with a link.
First off, realize that there is only so much you can do here on your end. You are allowing users to download a PDF, after which they can do with it what they please (legally or otherwise). So, preventing passing around the link is not necessarily going to prevent people from sharing or posting the PDF itself.
That said, if you do want to make it a little harder, you could do a variation of your suggestion #2 in which you institute a time delay of some kind before the link expires after it is clicked. You could also limit the number of times the link will serve the file. Because people have a variety of connection speeds, and because I do not know how large your PDFs are, I cannot say for sure what the time delay should be if you choose to use it.
Like I said, though, if someone is determined to share the file, they can easily do so.
Another possibility is that since you already know the persons email address, form a specific url for them in their email link.
So a user would click a link http://www.yourdomain.com/download_pdf.php?email=person#test.com
Keep a table with the following data for the email addresses.
id
email_addr
read_date
expire_date
When they click the link check to see if they've read it before and if they have check it hasn't expired. If it hasn't, serve the pdf to them, if it has give them a page that says "Sorry, your trial has expired../"
If its their first time clicking it then set the read_date and calculate the expiry date and set that.
Or optionally you could generate a hash or something and use the hash to id the user instead of their email address.
You could also set up a download column int he table and stop them from downloading it more than twenty times or something by incrementing the download column every time they click the link.

Trying to collect email analytics

I've written an email application in PHP that handles very large mailing lists. Is there a way to find out what emails are opened and by who? Any solution will do as long as it can tell me if the user has actually received and opened the email. I do not want to use email receipts either as it may put off recipients.
If it's relevant, I'm using the codeIgniter framework.
You can accomplish this by including a small tracking image in every email that is sent out.
<img src="http://yourdomain.com/tracking/1x1.gif?cId=12345&uId=56789">
Use mod-rewrite to push everything beyond '/tracking/' into your analytics script, snag the query_string and return a 1x1 gif to the email clients.
From Campaign Monitor:
http://help.campaignmonitor.com/topic.aspx?t=89
When each email is sent out, we
automatically add a piece of code that
requests a tiny, invisible image from
our web servers. So when a reader
opens the email, the image is
downloaded, and we can record that
download as an open for that specific
email.
It is important to understand that the
open rate is not a 100% accurate
measure. Recording an 'open' can only
happen if the reader's email client is
capable of displaying html with
images, and that option is turned on.
So if you are sending text-only
emails, there is no way to record open
rates. Similarly, people reading your
html email without images showing will
not be recorded as opens (unless they
click a link).
Another issue is that your readers may
have a preview pane in their email
client. That preview pane might be
displaying your email automatically
(and therefore downloading the images)
without the reader ever having to
click on it or read it.
So you should never take your open
rate as a hard and fast number,
because you can never know the true
figure. It is much better used as
general guide, and as a way of
measuring the trends on your email
campaigns.
You can put a tiny invisible img in each email, each image named differently to corespond with a specific email. Then you parse your access logs and see which images have been requested and you know which emails have been opened.
It's not fool proof but i've seen some companies use this method.
There's read receipts, but those are only supported by specific clients (ie, Outlook), and even then they are given the option to not notify you of their reading it.
The only other option is to communicate with your server when they read the email. To do this, you can implement a tracking pixel, which is a 1x1 transparent gif. You can intercept the response on your server and log the time, date, ip address, etc.
This still isn't foolproof though, because some clients such as gmail don't show images by default.
You can read more here: http://en.wikipedia.org/wiki/E-mail_tracking

How can I force email programs to show images send in html email using php?

I am sending an html email with php and it includes an image. Some email programs, such as gMail have a 'display images' button. The user has to click on that in order for the images in the email to show up.
Is there any way I can force email programs to show images that are sent within html emails generated by php?
As a rule of thumb, email clients are configured to display attached images by default (e.g. those with a cid: URI scheme) and not load remote images (which can include tracking information).
If you attach all the images, then you'll usually get them showing up (while inflating your SMTP bandwidth use along with that of your recipients (which can make you unpopular)).
I'm afraid not. The main reason email programs block images is because images are often used to 'report back' to whoever sent the email that the email has been opened. This is a common tactic used by spammers. Also, malicious code is often attached to images and downloading these images is how such code gets executed. Another reason email programs block images.
No, you can't force programs you didn't write yourself to do anything.
Email is hugely variable, and in general you're going to see different results in different places. That being said: There's no general way to force an email client to display images; this is why most email now includes a link at the top indicating that if it doesn't display correctly the user should click on it (which then takes the user to a standard HTML page outside the email client's image/javascript/everything-else-blocking grasp).
You specifically mention gmail so it's worth pointing out that if you embed (CID URI) the images they won't show inline, they'll show as attachments at the bottom of the message.
Doubt it, it would be a security issue if the 'src' of an image opened up a cross site scripting attack.
Cross site request forgery
Customers of a bank in Mexico were attacked in early 2008 with an
image tag in email and were sent
through their home routers to the
wrong website.
You can, but unfortunatley Trident, which is the IE rendering engine doesn't support it (surprise, surprise), but it is technically possible to include images in the html itself - see http://en.wikipedia.org/wiki/Data_URI_scheme
The last place I worked, we were sending out emails that had images in them that would come up automatically, in outlook at least, without me having to explicitly click a show images button.
When I inquired, another developer explained that they simply copied the encoded block of the image from an already sent email into the body of the email. I think this may be a weird sort of workaround they stumbled upon. I don't know if this adds more weight than an attachment, but I could see how an email reader would see an attachment and then ask the user as opposed to read it already in the body and just show it...

verify email opened

once we send email from php using mail() function, is there any way to check either mail is open or not?
may be any type of database insertion code in email..?
or calling any function from website?
any possibility.........
i search on internet all the day but did't found any ans.
Thanks
Small images - called Web Bugs - are the only direct way as Szere Dyeri points out, but they are increasingly frowned upon and blocked by every major mail client for privacy reasons now. I would not consider them a reliable way to tell whether an E-Mail has been read any more.
There is a legitimate way to request a read receipt by adding the following header to the E-Mail:
Disposition-Notification-To: your#address.com
Sending of this notification can be turned off by the recipient of course.
Add an invisible small sized image to the email content. And, let the image point to a unique url on your website. You will know that email is opened once that url is accessed. But this will not work in email clients that does not show images in the emails by default.
I found this web service called Get Notify. They claim they do this for free but you need to verify for yourself.
The only way to do this would be to include an image in the email that resided on your server which includes a key to match to the user you are sending the email to. For example, I send an email to Joe#mail.com. In my database (or other storage system) I have Joe#mail.com matched to key 0100. In his email I include an image, like
<img src="http://www.myserver.com/image/?key=0100" />
On your server, /image/ needs to return an image, even a 1 pixel .png. Now you have the key that the user was assigned and can act accordingly.
Many people responded that adding a "tracking image" is a "frowned upon" method and 'considered "questionable" activity'.
Out of curiosity lets say we didn't include a separate tracking image but rather we included this method in an existing image like for instance added it onto your companies logo image like:
http://mycompany.com/images/logo.png?track=2742'>
At least with this method your tracking image won't get blocked by any scanning applications.
One legitimate way to do this is to only send textual information in the email asking the user to follow a link which you can then track. Something along the lines of:
//lots of good info to identify yourself/company
Thank you for your request...
Please follow this link: http://somewhere/ for tracking information
Unfortunately this leaves it in the users hands to acknowledge your request. This is considered to be the most respectful way to do it.
If your application is not public facing (i.e. an internal app for your company), then the img src method already posted is a good technique.

Categories