I'm building a module related to transactional emails, and one of the things that it does is add click tracking to transactional emails.
The way that it currently is doing that is by overloading the email template model (fully compatible with SMTP Pro), parsing links, and rewriting them to a controller of mine:
I was thinking that perhaps a better approach would be to append query string variables to the original link:
The nice thing about this is that it doesn't introduce a new dependency on my module. So that if for some reason the module needed to be disabled, it could be done without emails that had already been sent out now having broken links in them.
I would need to add a
controller_action_predispatch observer to check for the existence of the query string variables and perform the click tracking.
But there may be a couple of downsides:
- Performance overhead - Not too concerned about this one - it takes under 10ms to perform a check in PHP for the query string variables
- FPC / Varnish - this one I'm a bit more concerned about - if the page is already cached by the time the user hits it, then the predispatch may not even run. The query string variables will be unique to the customer and the email they clicked on, so the URL itself will be reasonably unique, but if Varnish matches on the URL route and doesn't even care about the query string, then it will still get skipped.