How to Include an Unsubscribe Link

Follow this tutorial to include an unsubscribe link in promotional emails sent from Salesforce. My last post gives you some reasons for considering this feature.

131206-f-it851-005

So…you did that directly in production. I see…

When the recipient clicks to unsubscribe, a flow will look for ALL CONTACTS (not leads) who have this as their preferred email address (if you’re in NPSP) or in the Email field. All contacts who meet that requirement will be marked “Email Opt Out.”  The email address owner will receive one confirmation email immediately.

For goodness sake, please try this in your sandbox or a Trailhead playground first! 

The difficulty level for this tutorial is medium because of all the steps. You should know how to modify a page layout and a profile, create or modify an email template, and use a sandbox. You will install a package that contains Flow and Process Builder, but you don’t need to know how to use them.

  • Install package.
  • Set up my domain. Instructions on Trailhead.
  • Create a site (Setup -> User Interface -> Sites and Domains -> Sites)
    • Site Name & Label: Unsubscribe
    • Site Contact: yourself
    • Active Site Home Page: find the visualforce page Unsubscribe.
    • A default web address does not need to be specified.
    • Save and Activate.
    • Copy and save the Site URL for use in a later step.

site url

  • Click the Site label to go back into the Site again.
  • Click Public Access Settings.
    • Allow “Read” on the Contacts object and on the Email field on Contacts.
    • Allow Read, Create, Edit on custom object Unsubscribe. Give Edit access to all editable fields.
  • If you are using a sandbox or Trailhead playground that has the Nonprofit Success Pack installed, activate this Workflow: Contact_Preferred_Email__c. If not on NPSP, ignore this step.
  • Update variables in the flows
    • The variables in Flow called Unsubscribe.
      • OrganizationName – otherwise defaults to “our organization”
      • SenderAddress – otherwise defaults to fake@fake.com
      • ErrorRecipient – update with email address of user who should be notified when the person who wants to subscribe gets an error.
    • The variables in Flow called Unsubscribe2.
      • ErrorRecipient – update with email address of user who should be notified when the person who wants to subscribe gets an error.
    • How to update variables
      • Go to setup. Search for Flow. Open the flow Unsubscribe.
      • Follow the gif below, but on OrganizationName click “OK” instead of “Cancel.”

Variables

  • Click “Save As” and Close.
  • Activate this latest version of the Flow.
  • Insert the Unsubscribe link in your email template.
    • In Lightning:
      • Find Email Templates, by clicking on the App Launcher (the waffle in the top left corner.)
      • Search for “Email Templates.”
      • Open that, and click new to create a new template.
      • Click the button for source.
      • Paste In

Click here to unsubscribe from all emails.

  • In Classic, make an Email template that is Custom (without using Letterhead).
  • Paste In 

Click here to unsubscribe from all emails.

  • Replace with the Site URL you saved later. Mine would look like

snoringdog-developer-edition.na54.force.com/Unsubscribe?contactId={{{Recipient.Id}}}&Email={{{Recipient.Email}}}”>Click here to unsubscribe from all emails.

  • Save your template.
  • 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.
  • Edit your Contact page layout.
    • Add the Email Opt Out field.
    • Add the Unsubscribe related list. You may want to add other fields here like Unsubscribe Email, Created Date, Status
  • Create a contact with your email address.
  • TEST IT!
    • Send an email to that contact (using the template you created) to test it. Make sure the contact has “Email Opt Out” unchecked.
    • When you click the link it should look like this.

page1

  • The next page should look like this.

page2

  • 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.”

YOU DID IT!

Package Contains

  • Flows
    • Unsubscribe
    • Unsubscribe2
  • Process Builder
    • Contact Unsubscribe
  • Custom Object
    • Unsubscribe
      • Custom Fields
        • Contact__c
        • Unsubscribe_Email__c
        • Status
  • Visualforce Page
    • Unsubscribe
  • Report
    • Contacts who Unsubscribed This Month

How It Works Technically

Email recipient clicks link. This launches screen Flow Unsubscribe embedded in a Visualforce page asking if they are sure they want to unsubscribe. This page is the main page of a Site, which is set to be visible to external users. This flow creates a new Unsubscribe record – the external user has permission to create this kind of custom record (external users cannot modify standard objects). When that record is created, Process Builder Contact_Unsubscribe runs. This launches Flow Unsubscribe2 which finds all contact records with this email address as their preferred email and marks them Email Opt Out. If the whole process works successfully, the Unsubscribe record is marked as Status = “Unsubscribed”. If there is an error, Status = “Error” and an alert will be sent to person set as error recipient.

More resources

Feedback

Lemme know how it went if you try it out! Did it seem overwhelming and you didn’t try it? Share your thoughts!

Webinars

This post accompanies my new six part series Getting Started: Engagement for Nonprofits starting on Dec. 11 in which we’ll show you how to use Salesforce to connect with your constituents and track interactions over time. The first webinar in the six part Getting Started series will begin with the basics: what you can do today with Salesforce and Nonprofit Success Pack, to more effectively engage with your donors and community members. In later webinars, we’ll help you consider adding additional apps for outreach, marketing and communication. We’ll also share best practices for using Salesforce campaigns, engagement plans and levels. In the final webinars we’ll explore adding Marketing Cloud and Pardot for sophisticated marketing automation, and Community Cloud to deepen your constituent relationships.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s