Track Hyperlink Clicks With Mixpanel

Mixpanel allows you to easily track open rates of email messages with one click. But because there is no way to execute JavaScript within an email, tracking click-through rates of links sent within a Mixpanel email message is a bit trickier (albeit possible!). You can pass the $distinct_id through to identify the user before sending the event.

If the link in your Mixpanel email points to your own site or domain

In this case, the recommended method is to track an Event on the page rather than tracking the click activity itself from within the email. 

For example, let’s say the link in your email goes to the signup page on your site:

Append a custom query string param to this link, for example:

And if this query string param is present in the link, then send an Event, for example:

if(window.location.href.indexOf("emailclick") > -1){
     mixpanel.track("Email link clicked", {
          "Link name": window.location.href.split("emailclick=")[1]

If the link in your Mixpanel email does not point to your own site or domain

In this case, use Mixpanel’s HTTP spec to fire an Event, and use the redirect parameter to send the user to the desired URL. Your request will look something like this:

Replace the link in your email with this request; when clicked, the Event will fire and the user will be redirected to the destination URL.

Note: There is no way to place distinct_id in the track call above to tie clicks back to specific users, as you'd need to generate a unique link for every email. So if the link is to an external page, you will not be able to use this Event within Funnels or Retention. You will be able to use Insights to see how many times users in general clicked a particular link.

Is this article helpful?
6 out of 15 found this helpful



Article is closed for comments.