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:
- Host that 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/Generic SMTP. 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.
- 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).
- 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.