3

I am working on an email that will be sent out as a marketing effort. Within the email there will be a button that will allow people to "save the date" of the event and I want to be able to detect if the email was opened in gmail after the button is clicked, and if it was opened in gmail it would serve a Google Add to Calendar link - else it would serve an ICS file.

There is another email that does exactly this, it does not detect user agent since, regardless of the browser and os and device, if the email was opened in gmail it would redirect to google's add to calendar!

I've been trying to figure this out for a while now and have tried many trick, though none successful, I would love to see what other ideas people have.

Edit: I noticed that gmail will add data-saferedirecturl to all links

I'm wondering if there is a way to detect this?

Gurgen Grigoryan
  • 265
  • 1
  • 5
  • 17

2 Answers2

2

If you to know the source of the click on your link, you can do so by using a trick with images:

  1. Inside your mail, insert a tiny image pointing to your domain (Preferably with a different identifier for every recipient.
  2. When user first opens your mail, the Gmail proxy server will send your server a request to get the picture.
  3. You can identify the request coming from the Gmail proxy server using any of the indicative elements of the request (Like IP address, User-Agent and such).

Though, note that: If the recipient opens the mail again in Gmail, you won't see a request to your server, since this picture is saved in the proxy server's cache.

Tals
  • 468
  • 4
  • 17
  • If I am understanding correctly - I should point the link to an external domain - which I am currently doing - a blank html file, with some javascript to handle the redirect. I was attempting to get the http referrer, though I think gmail strips this data out. Im not sure what data too look out for in order to be able to detect if the user clicked the button in gmail or another email client/web mail client. – Gurgen Grigoryan Nov 16 '17 at 14:15
  • Hmm, interesting, I seem to have misread to original question. I updated my answer with a different solution – Tals Nov 16 '17 at 14:38
  • What would happen if the user came back to the email and tried to click the button again, which link would it serve? If it served the google add to calendar link previously? – Gurgen Grigoryan Nov 16 '17 at 14:55
  • Here's an idea - put a link to your domain in the mail. Then use your endpoint that receives the request to supply the tiny image to change the link redirection on-the-fly to decide between Google Calendar and an ICS file. Now your only problem will be with Gmail cache. This is not very solvable but I don't suppose you will run into this case much... – Tals Nov 16 '17 at 15:00
0

You cant pass javascript to mailreader. But you can add Email Tracking Pixel.

Utku Cansever
  • 180
  • 2
  • 16
  • Right now I have a button that links to a blank html file, with some javascript to handle the redirect. Like I said in another comment - I was attempting to get the http referrer, though I think gmail strips this data out. Im not sure what data too look out for in order to be able to detect if the user clicked the button in gmail or another email client/webmail client. – Gurgen Grigoryan Nov 16 '17 at 14:15