I am using swiftmailer , a library for sending mail in php. The problem is , I have already register a google analytic account.
How can I use this tool to check how many person have opened the email ?
Thank you.
Updated:
Ok, trackcode is in js , sure would not work. Images have some chance if the user allow it.
To be precise, what should i include in the image.php,
and is that mean i go to google analytics webpage and track the ../image.php?id=xxx then i can get result?
should i add the code in php?
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-29940706-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
You can't do it with 100% reliably. You can embed a webbug in the mail, but most mail clients automatically block any 3rd-party content from being loaded automatically. If the user doesn't say "ok, please load the images", then you'll never see the webbug hit come in.
You can request a return receipt on the email, but most mail clients will ignore that, or default to not sending one, or the user will decline to confirm receipt.
if you want to confirm that people have read the email, then your best bet is to NOT mail the content you want tracked, and simply send a LINK to that content:
"please click here to read an important announcement"
and the link would include a unique identifier tied to the particular email address the message was sent to. If you get a hit on that address, someone read the message and clicked the link, and the embedded tracking code will tell you who did so.
<img src="http://example.com/webbug.php?campaignID=XXX">
, but remember, it's pretty much guaranteed to NOT work. Mail clients don't load remote images unless explicitly authorized by the user - Marc B 2012-04-04 04:09
To get full Google Analytics integration for your newsletters, take a look at this official blog post addressing this subject:
http://analytics.blogspot.com/2009/03/tips-for-tracking-email-marketing.html?m=1