Implement tracking of Clicks for links in your email

Posted By : Yasir Zuberi | 30-Jun-2016

I am writing this blog to share with you a short and simple way of implementing tracking clicks of link included in your emails.


Let’s first take a look why do we really need to track clicks. When you send an email to your existing app users or potential users, it’s very common we add some sort of links in our emails sent. These could be links to a page where viewer can buy your product, link to a subscription page,  link to even un-subscribe or link to a third-party app and much more.


Now how would you know, whether recipient of email or how many recipients does actually clicked to link in your email and gets redirected to other web-apps.


Steps to implement click tracking is really simple


  • Create a url to your webapp which accepts required tracking info in parameters.
  • Refer all the links in emails you sent to this url
  • Once your url is requested, process the info received through parameters and return/redirects recipient to the desired link.

Here’s a sample code written in groovy and grails, you may apply the same other web application frameworks as well.


//Let’s assume you have created below link to track email clicks.

//Now based on above link, generate html’s anchor tag and include that in your email
Go To

class EmailTrackingController {
  def trackEmailClick() {
        System.out.println("Params received in Email Click request" + params);
    //Do Some Stuff. Processing Info of Clicks
//At the end redirects to desired url
       redirect uri: params.redirectTo



About Author

Author Image
Yasir Zuberi

Yasir is Lead Developer. He is a bright Java and Grails developer and have worked on development of various SaaS applications using Grails framework.

Request for Proposal

Name is required

Comment is required

Sending message..