Implementing 1-Click Unsubscribe in Salesforce Marketing Cloud

Warning: Oneclick unsubscribe policy could be destroying your email marketing efforts.

The legislation of most countries requires commercial emails to provide an avenue for the recipient to opt out of receiving subsequent messages.

The procedure of opting out of an email list is commonly referred to as e-mail unsubscribe. Besides the legal requirement, it is ethical to refrain from sending messages to those who do not want it.

Salesforce marketing cloud has a simple procedure of inserting a one-click unsubscribe link in every mail sent by the platform.

What is the importance of a One-Click Unsubscribe System?

By creating an avenue for your email recipients to unsubscribe themselves from your list, you can manage your list handsfree. You will appreciate the value of this system when you compare it to the arduous alternative of receiving “unsubscribe me” emails and manually removing users from your email list.

It is annoying when a user clicks on a unsubscribe link and they are presented with complicated pages requiring the user to perform further actions before getting out of a list. Such an email could be labelled as spam.

Salesforce Marketing Cloud presents its users with a standard unsubscribe feature as follows below:

<a href=”%%unsub_center_url%%” alias=”Unsubscribe”>Unsubscribe</a>,

However, this type of link is not a One-Click unsubscribe, it merely takes the user to the preference center.

The Salesforce unsubscribe system by default is set as below:

Publication List level unsubscribes: With this system, the recipient of an email clicks on a link and is immediately unsubscribed from a specific publication list which can be a newsletter, event, promotion campaign, etc.

Master unsubscribe: With this system, the recipient of the email clicks on a link and is directed to the preference centre or a custom page with an “Unsubscribe Fro All” button. After clicking the link, the user is removed from all list. An unsubscribe link that does not specify a publication list shall default to an “Unsubscribe From All” link.

Using the Publication List unsubscribe method is the best route to take as your subscriber can opt out of promotional emails and continue receiving other communications such as Newsletters.

Let’s take a closer look at the Salesforce Marketing warning regarding the unsubscribe from all:

“To unsubscribe this subscriber from all current and future subscriber lists, click the unsubscribe from all button”

A single click on that link will not only remove a subscriber from the current list, it will also bar such user from all future communications.

One-click unsubscribe from a Publication List

To implement a one-click unsubscribe from a specific publication list, you can use the AMPscript function LogUnsubEvent. This functions removes a subscriber and also logs an UnsubEvent trackable to a specific Job.

The LogUnsubEvent Execute call uses the following parameters:

  • SubscriberID – The is an auto-generated ID that uniquely identifies a Marketing Cloud subscriber.
  • SubscriberKey – The user-defined ID that uniquely identifies a subscriber.
  • EmailAddress – The email address of the subscriber.
  • JobID – The autogenerated ID of the Job that sent the message.
  • ListID – The ID of the List that the user is subscribed to. This can be a subscriber or publication lists (not suppression lists).
  • BatchID – The ID of the Batch within the Job.
  • Reason – (Optional) The reason for unsubscribing.

All the parameters above can be classified into three types, namely;

  • Subscriber context
  • Job context
  • Reason for unsubscribe

In a scenario where the script was launched from an Enterprise 2.0 account, you must include the ClientID of the child business account to be able to extract data that is specific to that business unit.

Bear in mind that the LogInsubEvent frequent will unsubscribe the subscriber from the email list and not from the All Subscriber List at the account level.

The One-Click Unsubscribe code is required to first obtain the parameters required for the LogUnsubEvent. See below

VAR @SubsKey, @JobID, @BatchID, @ListID, @reason

SET @SubsKey = AttributeValue(“_subscriberkey”)

SET @ListID = AttributeValue(“listid”)

SET @BatchID = AttributeValue(“_JobSubscriberBatchID”)

SET @JobID = AttributeValue(“jobid”)

SET @reason = “One-click Unsubscribe”

After parameters are obtained, you can create an object, set properties and execute the request.

 SET @lue = CreateObject(“ExecuteRequest”)

SetObjectProperty(@lue,”Name”,”LogUnsubEvent”)                                                   

SET @lue_prop = CreateObject(“APIProperty”)                

SetObjectProperty(@lue_prop, “Name”, “SubscriberKey”)

SetObjectProperty(@lue_prop, “Value”, @SubsKey)

AddObjectArrayItem(@lue, “Parameters”, @lue_prop)

 

SET @lue_prop = CreateObject(“APIProperty”)

SetObjectProperty(@lue_prop, “Name”, “JobID”)

SetObjectProperty(@lue_prop, “Value”, @JobID)

AddObjectArrayItem(@lue, “Parameters”, @lue_prop)

 

SET @lue_prop = CreateObject(“APIProperty”)

SetObjectProperty(@lue_prop, “Name”, “ListID”)

SetObjectProperty(@lue_prop, “Value”, @ListID)

AddObjectArrayItem(@lue, “Parameters”, @lue_prop)

           

SET @lue_prop = CreateObject(“APIProperty”)

SetObjectProperty(@lue_prop, “Name”, “BatchID”)

SetObjectProperty(@lue_prop, “Value”, @BatchID)

AddObjectArrayItem(@lue, “Parameters”, @lue_prop)

 

SET @lue_prop = CreateObject(“APIProperty”)

SetObjectProperty(@lue_prop, “Name”, “Reason”)

SetObjectProperty(@lue_prop, “Value”, @reason)

AddObjectArrayItem(@lue, “Parameters”, @lue_prop)

   

SET @lue_statusCode = InvokeExecute(@lue, @overallStatus, @requestId)

SET @mysub = CreateObject(“Subscriber”)

SetObjectProperty(@mysub, “Status”, “Unsubscribed”)

SetObjectProperty(@mysub, “SubscriberKey”, @SubscriberKey)

 

SET @statusCode = InvokeUpdate(@mysub, @statusMsg, @errorCode) 

/** They already exist on all subs **/

IF @statusCode != “OK” AND @errorCode == 12014 THEN

 SET @statusCode = InvokeUpdate(@mysub, @statusMsg, @errorCode)

ENDIF

 

This code should be placed in a micro site or a cloud page. After that, the  AMPscript function MicrositeURL(PageID) or CloudePageURL(PageID) can be used to initiate the One Click Unsubscribe Landing Page from email. The page ID can be extracted from the landing page or cloud page properties.  E.g

PageID:1718

Url: https://pages.exacttarget.com/page.aspx?QS:

One-click unsubscribe from All

For the one-click Unsubscribe From All event, the code is much simpler and the LogUnsubEvent function is not applicable.

VAR @SubsKey

SET @SubsKey = AttributeValue(“_subscriberkey”)

 

SET @mysub = CreateObject(“Subscriber”)

SetObjectProperty(@mysub, “Status”, “Unsubscribed”)

SetObjectProperty(@mysub, “SubscriberKey”, @SubsKey)

 

SET @statusCode = InvokeUpdate(@mysub, @statusMsg, @errorCode)

/** They already exist on all subs **/

IF @statusCode != “OK” AND @errorCode == 12014 THEN

 SET @statusCode = InvokeUpdate(@mysub, @statusMsg, @errorCode)

ENDIF

Troubleshooting

Web Analytics connector causes the custom unsubscribe link to malfunction when clicked within an email. It is normal for the unsubscribe link to contain a question mark (?). The web analytics connector adds a second question mark (?) instead of a string “&” which bungles the URL.  We can help to resolve this issue, just get in touch.