Skip to content

Instantly share code, notes, and snippets.

@MamaiRachid
Last active October 20, 2020 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MamaiRachid/0bad2e10800c478bc69972e0dee6e377 to your computer and use it in GitHub Desktop.
Save MamaiRachid/0bad2e10800c478bc69972e0dee6e377 to your computer and use it in GitHub Desktop.
Unsubscribe from Newsletter by creating a Task on SalesCloud. SFMC - Data Privacy Manager
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Unsubscribe - Newsletter</title>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Bootstrap -->
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<style>
body {
font-family: 'Montserrat', sans-serif;
color: #412761
}
</style>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
%%[
SET @emailaddr = AttributeValue("emailaddr")
SET @subKey = AttributeValue("_subscriberkey")
/* Get the NewsletterEmail_Consent value from Consents Data Extension */
SET @rowsConsents = LookupRows("Consents", "SubscriberKey", @subKey)
IF RowCount(@rowsConsents) > 0 then
SET @consentRow = Row(@rowsConsents,1)
SET @newsletterEmail_Consent = Field(@consentRow, "NewsletterEmail_Consent")
ENDIF
/* Check if the contact is subscribed to the newsletterEmail_Consent */
IF (@newsletterEmail_Consent != 'False') THEN
SET @timeNow = FormatDate(Now(),"iso")
SET @created_taskId= CreateSalesforceObject('Task',4,'WhoId', @subKey, 'Subject', 'Datapm:Unsubscribe', 'Description', '{"crCode":"100001"}', 'ActivityDate', @timeNow)
/* Update Consents Data Extension */
UpsertData("Consents", 1, "SubscriberKey", @subKey, "NewsletterEmail_Consent", "False")
ENDIF
]%%
</head>
<body>
<!-- Logo start-->
<div class="row" style="background-color:#ab5643;">
<div class="col-md-3" style="margin-left:5%;margin-top:1%;margin-bottom:2%;">
<img width="250px" height="100px" src="YOUR_LOGO_LINK" alt="" id="logo"/>
</div>
<div class="col-md-9">
</div>
</div>
<!-- Logo end-->
<!-- body start-->
<div class="row" style="background-color:#ffffff;">
<div class="col-md-3">
</div>
<div class="col-md-6" >
<h3 style="margin:3%;margin-top: 20%;margin-bottom: 20%;">Sorry to see you go, the email %%=v(@emailaddr)=%% has been unsubscribed from our Newsletter. It will be effective in 48 hours.
</h3>
</div>
<div class="col-md-3">
</div>
</div>
<!-- body end-->
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment