Unsubscribe Link 2.2

Allow Recipients to Unsubscribe From All Email Sent via Salesforce

When the recipient clicks to unsubscribe, a flow will look for all contacts and leads who have this email in the Email field and mark them “Email Opt Out.”  The email address owner will receive one confirmation email immediately. A custom object tracks when someone unsubscribes to allow you to report on it.

See How It Works

Set Up Instructions

Install the latest version from the AppExchange.

Make sure My Domain is set up. Instructions here from Trailhead.

Create a Site

  • (Setup -> User Interface -> Sites and Domains -> Sites)
  • Create a new Site.
  • If you don’t have a Site domain, you’ll need to set one up. You may want to use the same domain as your “My” domain.
  • Label: Make the label the name of your organization or whomever the confirmation email should appear from. I will put “Ugly Dog Adoption Agency” and the unsubscribe confirmation email will appear from “Ugly Dog Adoption Agency Site Guest User.”
  • Site Name: Unsubscribe (so internally you know what this is about).
  • Site Contact: Defaults to your user.
  • Click Active.
  • Active Site Home Page: select the Visualforce page Unsubscribe.
  • A default web address does not need to be specified.
  • Save.
  • Click on the button Public Access Settings at the top.
  • Give the Site Guest user access to the Visualforce page UnsubscribeFinish:
    • Click on Visualforce Page Access then Edit.
    • Add the Visualforce Page UnsubscribeFinish to the Enabled Visualforce Pages list.
    • Save.
  • Go back to the main page for Sites.
  • In the top section of the page under “What is a Site?” look for the box that says “Your Salesforce site domain is” and copy the value there for the next step for when you modify the Custom Metadata Type.
This image has an empty alt attribute; its file name is SiteDomain.jpg

Modify the Custom Metadata Type

  • In Setup, search for and click on Custom Metadata Types.
  • Click Manage Records to the left of Unsubscribe Link.
  • Click the record Unsubscribe.
  • In Site Domain, paste in the site domain you created earlier.
  • In Our Organization, type in the name of your organization or company. This will appear in the unsubscribe link and the flow screens.
  • In Comma Separated Email List make a list of email addresses you’d like to receive custom error messages when the Flows have errors. I’d put your own email so you can troubleshoot while you’re setting this up. These are additional emails beyond the emails the system sends with an error.

Field and Object Level Security

  • Give the appropriate users access to:
    • Unsubscribe Link fields for Contact and Lead. Give this field visibility to anyone sending commercial/promotional email out of Salesforce.
    • Unsubscribe__c object and its fields for anyone tracking the frequency of unsubscribes.

Test It Out

  • In your sandbox, make sure Email Deliverability is turned on.
    • Go to setup. Search for “Deliverability.”
    • Set the access level to “All email.”
    • Be very careful if you are using a sandbox with real data – do you have any automated processes that are now going to start firing off emails like crazy? Remember to turn off email deliverability when you’re done testing.
  • Optional: Edit your Contact and Lead page layouts.
    • Add the Email Opt Out field.
    • Add the Unsubscribe related list. You may want to add other fields here like Unsubscribe EmailCreated DateStatus.
  • Create a contact with your email address.
  • Send a test email.
    • Send an email to that contact and insert the Unsubcribe Link merge field into an email. Make sure the contact has “Email Opt Out” unchecked.
    • When you click the link it should look like this.
This image has an empty alt attribute; its file name is applefence.png

The next page should look like this.

Image of text that says: "Thank you. You have successfully unsubscribed. You will receive a confirmation email shortly."
  • Look for that confirmation email.
  • Open the contact record and confirm the following:
    • Email opt out is now checked
  • There is a new related Unsubscribe record and Status = “Unsubscribed.”

Success!

How to Uninstall the Package

If you have any Unsubscribe__c records from using this package, you’ll lose them by uninstalling.

  • Deactivate the Flows: Unsubscribe Link, UnsubscribeContactsv1, UnsubscribeLeadsv1.
  • Open the record for your Site.
  • From Setup, search for “Installed Packages” and uninstall.

One Comment

Leave a Reply