Custom Unsubscribe Links & Landing Pages

The Messaging and Mobile A/B testing features are not available for purchase and will be deprecated from the product on January 1st, 2022. Read more information on the Mixpanel blog.

By default, Mixpanel directs users who click on the unsubscribe link from emails to a Mixpanel-hosted unsubscribe page. This page runs a script that sets a user profile property $unsubscribed, with the value set to the timestamp the user unsubscribed - to that user’s profile. This prevents the user from receiving any more emails from that project, but does not globally unsubscribe them from Mixpanel messages such as in-app messages or push notifications.

However, it is possible to redirect users who click on the unsubscribe link from a Mixpanel email message to your own domain. This gives you a chance to re-engage with those customers one last time or style the page to match your site’s design.


  • You must either be setting users’ distinct_ids as an additional property on their profiles; OR

  • You must be setting a different user ID, like email address or username, that is aliased to the Mixpanel distinct_id as a property on their profiles.

Setup Custom Unsubscribe Link

To add custom text to Mixpanel's default unsubscribe link, add custom HTML to match the style or text you are looking for. Here's how the HTML will look:

<a href="<< unsub >>">My custom unsubscribe link text</a>

To redirect users to your website to unsubscribe, add your website URL as shown in the HTML below: 

<a href="">My custom unsubscribe link text</a>

Setup Landing Page

Your custom unsubscribe link will then look something like this - in this example, we’re using $distinct_id:

<a href="{{ user['$distinct_id'] }}">Unsubscribe</a>

Now on the unsubscribe page (, we will use our function to grab the value for “id.” However, instead of setting this value as a super property, we will use it as the distinct_id of a people set. This will allow us to set the “$unsubscribed=True” property to that specific user’s profile:

function getQueryParam(param) {
    param = param.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + param + "=([^&#]*)",
        regex = new RegExp( regexS ),
        results = regex.exec(document.URL);
    if (results === null || (results && typeof(results[1]) !== 'string' && results[1].length)) {
        return '';
    } else {
        return decodeURIComponent(results[1]).replace(/\+/g, ' ');

var distinct_id = getQueryParam("id");
mixpanel.people.set({"$unsubscribed":"true"}); mixpanel.track("$unsubscribe",{ "Campaign ID": campaign name, });

Once your custom unsubscribe page is built, remember to uncheck the default unsubscribe option on your emails, and insert the link to your custom unsubscribe page at the end of your email instead:


Did this answer your question?



Article is closed for comments.