Documentation > Integrating e-mail providers

Handling Unsubscriptions

Handling Unsubscriptions

If you’re using Amazon SES or your own SMTP gateway, you’ll have to follow these steps to enable your users to unsubscribe from your email notifications:

  • Download this email unsubscription HTML template file from here – http://static.clevertap.com/docs/email-unsubscribe.html. You can beautify or brand this template file if needed. Just ensure that the original JavaScript functions are retained.
  • Host the above downloaded file at a publicly accessible server. The extension of the file could be anything, even PHP if you want some backend logic of yours to go in there.
  • Go to the CleverTap Dashboard → Settings → Amazon SES. Now fill in the URL of the unsubscribe page – no parameters, just the URL. e.g. http://foobar.com/unsubscribe.html
  • Now when you’re composing the email, in the body, put the unsubscribe link as shown below. CleverTap will replace *|UNSUBSCRIBE|* with the actual URL of the unsubscribe page at the time of sending out the email

Understanding the Unsubscription flow

  • When an email notification campaign is sent out, CleverTap will automatically replace the *|UNSUBSCRIBE|* link in the body of the email with the location of your page.
  • When a user clicks on the unsubscribe link in your email, the user will be taken to the unsubscribe page.
  • On body load call the $WZRK_WR.getEmail() method, which will call the wzrk_email_fetched(emailStr) method on that page when the email is fetched from the server.
  • Call the unsubscribe() method when the user confirms that they want to unsubscribe.
  • You can call the resubscribe() method when the user wants to resubscribe to the email (this is only valid if the user first unsubscribed, and is still on that page from the earlier link).

Troubleshooting

  • The unsubscription link will not work for test emails sent from the notification creation page.
  • Make sure that when a user lands on the unsubscription page, the URL has these params:
    e :this contains some meta data about the user
    wzrk_ex : this is a CleverTap internal parameter