How to create Custom Unsubscribe Page – Marketing Cloud

Here is the method using which you can create custom Unsubscribe page for your Emails.

You need to follow below steps:
1. Create Classic Cloud page (HTML).
2. Then you need to include below ampscript code in it:

<script>
%%[
 VAR @sid, @jid, @listid, @batchid, @reason, @lue, @lue_prop, @lue_statusCode, @overallStatus, @requestId, @lue_Response, @lue_Status, @lue_Error
 SET @sid = IIF(Empty(RequestParameter("email_address")),RequestParameter("current_email_address"),RequestParameter("email_address"))
 set @em = RequestParameter("SID")
 SET @jid = RequestParameter("JID")
 SET @listid = RequestParameter("LID")
 SET @batchid = RequestParameter("JSB")
 SET @reason = "Landing Page Unsubscribe"
 SET @lue = CreateObject("ExecuteRequest")
 SetObjectProperty(@lue,"Name","LogUnsubEvent")
 SET @lue_prop = CreateObject("APIProperty")
 SetObjectProperty(@lue_prop, "Name", "SubscriberID")
 SetObjectProperty(@lue_prop, "Value", @em)
 AddObjectArrayItem(@lue, "Parameters", @lue_prop)
 SET @lue_prop = CreateObject("APIProperty")
 SetObjectProperty(@lue_prop, "Name", "JobID")
 SetObjectProperty(@lue_prop, "Value", @jid)
 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 @lue_Response = Row(@lue_statusCode, 1)
 SET @lue_Status = Field(@lue_Response,"StatusMessage")
 SET @lue_Error = Field(@lue_Response,"ErrorCode")
 ]%%
</script>

3. Add Unsubscribe page link in Template:

<a href="%%=RedirectTo(CloudPagesURL(368))=%%" alias="ThisAlias" conversion="false" > unsubscribe</a>

368 is the Cloud Page Id – Get into Cloud Page details to get your cloud Page Id.

You Unsubscribe page is ready.

Thank you.

Note : Replace double quotes ” with proper HTML quote otherwise you’ll get 500 error.

Leave a Comment