Pergunta

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:

http://sitename.com/module/redirect/index/?link=http%3A%2F%2Fsitename.com/originallink/

I was thinking that perhaps a better approach would be to append query string variables to the original link:

http://sitename.com/originallink/?clicktrack=1&...

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.
Foi útil?

Solução 2

Decided to implement my own controller for click-tracking. Not quite as a clean in terms of dependencies, but one way to avoid 404's after having disabled the module would be simply to setup a redirect from that route to the home page.

Outras dicas

Use the google url builder get a good campaign url: https://support.google.com/analytics/answer/1033867?hl=en

It will take your base url and create a tracking url based on your info that you add and presents a link like: http://www.savethemage.com/?utm_source=Newsletter&utm_medium=Email&utm_content=Logo&utm_campaign=Order+Confirmation

Then take the part starting with ?: ?utm_source=Newsletter&utm_medium=Email&utm_content=Logo&utm_campaign=Order+Confirmation

and add it to the transaction email template for each link you want to track. Make sure you change the utm_content= to something unique for each link.

Then analytics will track all of those clicks.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange
scroll top