Created
November 9, 2020 11:34
-
-
Save PrafullJain/5161cb1befbb8954c24dd7493d19c6e1 to your computer and use it in GitHub Desktop.
In this Gist You can See How we can Update the All Subscriber List Attributes,(Status, FirstName, LastName & others as well) & How to update Status in Publication List as well as on My Lists Options for List type Table. Not for Suppression List.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta | |
name="viewport" | |
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" | |
/> | |
<title>Profile Centre</title> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"> | |
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.bundle.min.js"> | |
<style> | |
.switch { | |
position: relative; | |
display: inline-block; | |
width: 50px; | |
background: rgba(0, 0, 0, 0.25); | |
height: 22px; | |
border-radius: 20px; | |
transition: all 0.3s; | |
} | |
.switch::after { | |
content: ''; | |
position: absolute; | |
width: 18px; | |
height: 18px; | |
border-radius:50%; | |
background-color: white; | |
top: 1px; | |
left: 1px; | |
transition: all 0.3s; | |
} | |
.checkbox:checked + .switch::after { | |
left : 30px; | |
} | |
.checkbox:checked + .switch { | |
background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/checkmark-switcher.svg); | |
background-color:#00d084; | |
} | |
.checkbox { | |
display : none; | |
} | |
label | |
{ | |
margin:1vh | |
} | |
legend | |
{ | |
padding-top: 3vw; | |
font-size:30px; | |
text-decoration:underline; | |
} | |
img | |
{ | |
border-radius:50%; | |
width:150px; | |
} | |
fieldset | |
{ | |
width: 45vw; | |
max-width: 50vw; | |
background: #12c2e9; | |
background: -webkit-linear-gradient(to right, #f64f59, #c471ed, #12c2e9); | |
background: linear-gradient(to right, #f64f59, #c471ed, #12c2e9); | |
border-top-left-radius:50px; | |
border-bottom-right-radius:50px; | |
border: 2px solid #017a9b; | |
box-shadow: 10px 10px 15px rgba(0, 0, 0, 0.5); | |
} | |
a | |
{ | |
background-image: url(https://4.bp.blogspot.com/-Iv0jK4QOIcY/WHw0v9AHscI/AAAAAAAABhI/FZdWGg65s4YVyl8CgSZdvmcA1L3f2SzBwCLcB/s1600/End%2BLine.gif); | |
color: greenyellow; | |
border-radius: 22px; | |
font-size: 20px; | |
padding: 10px; | |
display: block; | |
line-height: 25px; | |
} | |
input | |
{ | |
margin:3vh; | |
} | |
form | |
{ | |
box-shadow: 5px 17px 30px 25px rgba(0, 0, 0, 0.5); | |
border-top-left-radius: 30px; | |
border-bottom-right-radius: 30px; | |
border: 2px solid springgreen; | |
margin-bottom: 3vh; | |
} | |
input[type=submit] | |
{ | |
line-height: 1; | |
margin: 0.5em; | |
outline: none !important; | |
padding: 0.4em 1em; | |
background: lightblue; | |
border-radius: 15px; | |
font-size: 22px; | |
font-family: "Comic Sans MS", cursive, sans-serif; | |
border-color: aquamarine; | |
box-shadow: 5px 17px 30px 8px rgba(0, 0, 0, 0.5); | |
} | |
input[type=text] | |
{ | |
padding: 10px 5px; | |
border: 2px solid cyan; | |
border-radius: 9px; | |
outline: none !important; | |
transition: border-color .1s ease-in-out,box-shadow .1s ease-in-out; | |
} | |
input[type=email]{ | |
padding: 10px 5px; | |
border: 2px solid cyan; | |
border-radius: 9px; | |
margin-left: 40px; | |
outline: none !important; | |
transition: border-color .1s ease-in-out,box-shadow .1s ease-in-out; | |
} | |
input[type=text]:focus | |
{ | |
padding: 10px 5px; | |
outline: none !important; | |
border: 2px solid magenta; | |
border-radius: 9px; | |
box-shadow: 0 0 8px 0 rgba(17,22,26,.16), 0 4px 8px 0 rgba(17,22,26,.08), 0 8px 16px 0 rgba(17,22,26,.08); | |
} | |
input[type=email]:focus{ | |
padding: 10px 5px; | |
outline: none !important; | |
border: 2px solid magenta; | |
border-radius: 9px; | |
box-shadow: 0 0 8px 0 rgba(17,22,26,.16), 0 4px 8px 0 rgba(17,22,26,.08), 0 8px 16px 0 rgba(17,22,26,.08); | |
} | |
body | |
{ | |
background-image:url('https://demo.w3layouts.com/demos_new/template_demo/25-01-2018/user_profile_form-demo_Free/1137453614/web/images/bg1.jpg'); | |
font-size:18px; | |
font-family: "Comic Sans MS", cursive, sans-serif; | |
background-size: cover; | |
background-position: bottom; | |
background-repeat:no-repeat; | |
background-attachment: fixed; | |
} | |
.raise:hover, | |
.raise:focus { | |
box-shadow: 0 0.5em 0.5em -0.4em red; | |
transform: translateY(-0.32em); | |
} | |
</style> | |
</head> | |
<body> | |
%%[ | |
SET @subscriberKey = [_subscriberkey] | |
// PROFILE ATTRIBUTES | |
SET @emailAddress = [emailaddr] | |
SET @genderMale = IIF([gender] == "Male", "checked", "") | |
SET @genderFemale = IIF([gender] == "Female", "checked", "") | |
]%% | |
<script runat="server" language="JavaScript"> | |
Platform.Load("core","1.1.2"); | |
var sk = Variable.GetValue("@subscriberKey"); | |
var subscriberObj = Subscriber.Init(sk); | |
var attributes = subscriberObj.Attributes.Retrieve(); | |
var attr=Stringify(attributes); | |
Variable.SetValue("@fsName", Stringify(attributes[0]["Value"])); | |
Variable.SetValue("@lsName", Stringify(attributes[1]["Value"])); | |
var subscriptionStatus = Subscriber.Retrieve({ | |
Property: "SubscriberKey", | |
SimpleOperator: "equals", | |
Value: Variable.GetValue("@subscriberKey") | |
} | |
); | |
if(subscriptionStatus[0].Status == "Active") { | |
Variable.SetValue("subscriptionStatus", true); | |
} | |
else { | |
Variable.SetValue("subscriptionStatus", false); | |
} | |
// POST VARIABLES | |
var subscriberKey = Platform.Request.GetFormField('subscriberKey') || ""; | |
var firstName = Platform.Request.GetFormField('firstName') || ""; | |
var lastName = Platform.Request.GetFormField('lastName') || ""; | |
var email = Platform.Request.GetFormField('email') || ""; | |
var gender = Platform.Request.GetFormField('gender') || ""; | |
var unsubscribe = Platform.Request.GetFormField('unsubscribe') || false; | |
var subscribeTo = Platform.Request.GetFormField('subscribe') || false; | |
try{ | |
if(subscriberKey) { | |
var subscriberData = { | |
"EmailAddress":email, | |
"Attributes": { | |
"First Name" : firstName, | |
"Last Name" : lastName | |
} | |
}; | |
if(gender != "") { | |
subscriberData.Attributes.Gender = gender; | |
} | |
if(subscribeTo) { | |
subscriberData.Status = "Active"; | |
} | |
var subObj = Subscriber.Init(subscriberKey); | |
if(unsubscribe) { | |
var unsubscribeSatus = subObj.Unsubscribe(); | |
Variable.SetValue("unsubscribeSatus", unsubscribeSatus); | |
} | |
else { | |
var udpateStatus = subObj.Update(subscriberData); | |
Variable.SetValue("unsubscribeSatus", (subscribeTo && udpateStatus)?"SUBSCRIBED":"NA"); | |
Variable.SetValue("udpateStatus", udpateStatus); | |
} | |
Variable.SetValue("formSubmitted", true); | |
} | |
else { | |
Variable.SetValue("formSubmitted", false); | |
} | |
</script> | |
<center> | |
<fieldset> | |
<legend align="center"> | |
Update Your Profile<br/> | |
</legend> | |
<form method="POST"> | |
<center> | |
<img src='https://pngimage.net/wp-content/uploads/2018/05/avatar-profile-png-3.png'/> | |
</center> | |
<input type="hidden" name="subscriberKey" value="%%=v(@subscriberkey)=%%"> | |
<label>First Name: </label> | |
<input type="text" name="firstName" value=%%=v(@fsName)=%% %%[IF @subscriptionStatus ==false THEN]%% disabled title='Please subscribe to us' %%[ENDIF]%%> | |
<br> | |
<label>Last Name: </label> | |
<input type="text" name="lastName" value=%%=v(@lsName)=%% %%[IF @subscriptionStatus ==false THEN]%% disabled title='Please subscribe to us' %%[ENDIF]%% > | |
<br> | |
<label>* Email: </label> | |
<input type="email" required name="email" value="%%=v(@emailAddress)=%%" %%[IF @subscriptionStatus ==false THEN]%%disabled title='Please subscribe to us' %%[ENDIF]%% > | |
<br> | |
<label>Gender: </label> | |
<input type="radio" name="gender" value="Male" %%=v(@genderMale)=%% %%[IF @subscriptionStatus ==false THEN]%%disabled title='Please subscribe to us' %%[ENDIF]%%> Male | |
<input type="radio" name="gender" value="Female" %%=v(@genderFemale)=%% %%[IF @subscriptionStatus ==false THEN]%%disabled title='Please subscribe to us' %%[ENDIF]%%> Female | |
<br> | |
<br/> | |
<br/> | |
<div style="max-width:120vw;color:black;font-size:22px;text-decoration:underline"> | |
<label >%%=IIF(@subscriptionStatus, "Unsubscribe from all", "Resubscribe")=%%</label> | |
<br> | |
<input name='%%=IIF(@subscriptionStatus, "unsubscribe", "subscribe")=%%' value="true" type="checkbox" id="toggle1" class="checkbox" > | |
<label for="toggle1" class="switch" style="background-repeat: no-repeat;"></label> | |
<br>You are %%=IIF(@subscriptionStatus, "subscribed to", "unsubscribed from")=%% us!. | |
<br/> | |
<br/> | |
</div> | |
<input type="submit" value="Update" class="raise"> | |
</form> | |
<a href="%%=RedirectTo(CloudPagesURL(558))=%%" alias="Manage Your Subscriptions" title="Manage Your Subscriptions" >Manage Your Subscriptions</a> | |
</fieldset> | |
</center> | |
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10.3.5/dist/sweetalert2.all.min.js"></script> | |
%%[ IF @formSubmitted AND @udpateStatus == "OK" AND @unsubscribeSatus == "NA" THEN ]%% | |
<script> | |
Swal.fire("Updated!", "Your preferences are updated successfully", "success").then(() => { | |
location.href = location.href; | |
} | |
); | |
</script> | |
%%[ ELSEIF @formSubmitted AND @udpateStatus == "Error" AND @unsubscribeSatus == "NA" THEN ]%% | |
<script> | |
Swal.fire("Not Updated!", "Something went wrong while updating your preferences", "error").then(() => { | |
location.href = location.href; | |
} | |
); | |
</script> | |
%%[ ELSEIF @formSubmitted AND @unsubscribeSatus == "OK" THEN ]%% | |
<script> | |
Swal.fire("Unsubscribed!", "Sorry to see you go away!", "info").then(() => { | |
location.href = location.href; | |
} | |
); | |
</script> | |
%%[ ELSEIF @formSubmitted AND @unsubscribeSatus == "SUBSCRIBED" THEN ]%% | |
<script> | |
Swal.fire("Subscribed!", "Happy to see you again!<br/>We make sure we don't spam you!!", "success").then(() => { | |
location.href = location.href; | |
} | |
); | |
</script> | |
%%[ ELSE ]%% | |
%%[ ENDIF ]%% | |
<script runat="server"> | |
} | |
catch(ex) { | |
Write("<p style='color:red'>"+Stringify(ex)+"</p>"); | |
} | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" /> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
<title>Subscription Centre | |
</title> | |
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"> | |
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.bundle.min.js"> | |
<style> | |
.switch { | |
position: relative; | |
display: inline-block; | |
width: 50px; | |
background: rgba(0, 0, 0, 0.25); | |
height: 22px; | |
border-radius: 20px; | |
transition: all 0.3s; | |
} | |
.switch::after { | |
content: ''; | |
position: absolute; | |
width: 18px; | |
height: 18px; | |
border-radius:50%; | |
background-color: white; | |
top: 1px; | |
left: 1px; | |
transition: all 0.3s; | |
} | |
.checkbox:checked + .switch::after { | |
left : 30px; | |
} | |
.checkbox:checked + .switch { | |
background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/checkmark-switcher.svg); | |
background-color:#00d084; | |
} | |
.checkbox { | |
display : none; | |
} | |
label | |
{ | |
margin:1vh | |
} | |
legend | |
{ | |
padding-top: 3vw; | |
font-size:30px; | |
text-decoration:underline; | |
} | |
img | |
{ | |
border-radius:50%; | |
width:150px; | |
} | |
fieldset | |
{ | |
width: 45vw; | |
max-width: 50vw; | |
background: #12c2e9; | |
background: -webkit-linear-gradient(to right, #f64f59, #c471ed, #12c2e9); | |
background: linear-gradient(to right, #f64f59, #c471ed, #12c2e9); | |
border-top-left-radius:50px; | |
border-bottom-right-radius:50px; | |
border: 2px solid #017a9b; | |
box-shadow: 10px 10px 15px rgba(0, 0, 0, 0.5); | |
} | |
a | |
{ | |
background-image: url(https://4.bp.blogspot.com/-Iv0jK4QOIcY/WHw0v9AHscI/AAAAAAAABhI/FZdWGg65s4YVyl8CgSZdvmcA1L3f2SzBwCLcB/s1600/End%2BLine.gif); | |
color: greenyellow; | |
border-radius: 22px; | |
font-size: 20px; | |
padding: 10px; | |
display: block; | |
line-height: 25px; | |
} | |
input | |
{ | |
margin:3vh; | |
} | |
form | |
{ | |
box-shadow: 5px 17px 30px 25px rgba(0, 0, 0, 0.5); | |
border-top-left-radius: 30px; | |
border-bottom-right-radius: 30px; | |
border: 2px solid springgreen; | |
margin-bottom: 3vh; | |
line-height: 45px; | |
} | |
input[type=submit] | |
{ | |
line-height: 1; | |
margin: 0.5em; | |
outline: none !important; | |
padding: 0.4em 1em; | |
background: lightblue; | |
border-radius: 15px; | |
font-size: 22px; | |
font-family: "Comic Sans MS", cursive, sans-serif; | |
border-color: aquamarine; | |
box-shadow: 5px 17px 30px 8px rgba(0, 0, 0, 0.5); | |
} | |
input[type=text] | |
{ | |
padding: 10px 5px; | |
border: 2px solid cyan; | |
border-radius: 9px; | |
outline: none !important; | |
transition: border-color .1s ease-in-out,box-shadow .1s ease-in-out; | |
} | |
input[type=email]{ | |
padding: 10px 5px; | |
border: 2px solid cyan; | |
border-radius: 9px; | |
margin-left: 40px; | |
outline: none !important; | |
transition: border-color .1s ease-in-out,box-shadow .1s ease-in-out; | |
} | |
input[type=text]:focus | |
{ | |
padding: 10px 5px; | |
outline: none !important; | |
border: 2px solid magenta; | |
border-radius: 9px; | |
box-shadow: 0 0 8px 0 rgba(17,22,26,.16), 0 4px 8px 0 rgba(17,22,26,.08), 0 8px 16px 0 rgba(17,22,26,.08); | |
} | |
input[type=email]:focus{ | |
padding: 10px 5px; | |
outline: none !important; | |
border: 2px solid magenta; | |
border-radius: 9px; | |
box-shadow: 0 0 8px 0 rgba(17,22,26,.16), 0 4px 8px 0 rgba(17,22,26,.08), 0 8px 16px 0 rgba(17,22,26,.08); | |
} | |
body | |
{ | |
background-image:url('https://demo.w3layouts.com/demos_new/template_demo/25-01-2018/user_profile_form-demo_Free/1137453614/web/images/bg1.jpg'); | |
font-size:18px; | |
font-family: "Comic Sans MS", cursive, sans-serif; | |
background-size: cover; | |
background-position: bottom; | |
background-repeat:no-repeat; | |
background-attachment: fixed; | |
} | |
.raise:hover, | |
.raise:focus { | |
box-shadow: 0 0.5em 0.5em -0.4em red; | |
transform: translateY(-0.32em); | |
} | |
</style> | |
</head> | |
<body> | |
%%[ | |
SET @sk =[_subscriberkey] | |
SET @emailAddress = [emailaddr] | |
]%% | |
<script runat="server" language="JavaScript"> | |
Platform.Load("core", "1"); | |
var email = Variable.GetValue("@emailAddress"); | |
var subscriptionStatus = Subscriber.Retrieve({ | |
Property: "SubscriberKey", | |
SimpleOperator: "equals", | |
Value: Variable.GetValue("@sk") | |
} | |
); | |
if(subscriptionStatus[0].Status == "Active") { | |
Variable.SetValue("subscriptionStatus", true); | |
} | |
else { | |
Variable.SetValue("subscriptionStatus", false); | |
} | |
// POST VARIABLES | |
var subscriberKey = Platform.Request.GetFormField('subscriberKey') || ""; | |
var unsubscribe = Platform.Request.GetFormField('unsubscribe') || false; | |
var subscribeTo = Platform.Request.GetFormField('subscribe') || false; | |
var activeLsNameWithId = Platform.Request.GetFormField('activeListName') || ""; | |
var tempActiveLsNameId = activeLsNameWithId.toString().split(','); | |
var correctActiveLsId = []; | |
if(tempActiveLsNameId.length > 0) { | |
for(var i = 0; i < tempActiveLsNameId.length; i++) { | |
var st = tempActiveLsNameId[i].split(':'); | |
correctActiveLsId.push(st[1]); | |
} | |
} | |
/******************************************************************/ | |
function arrayDiff(a1, a2) { | |
var a = [], | |
diff = []; | |
for(var i = 0; i < a1.length; i++) { | |
a[a1[i]] = true; | |
} | |
for(var i = 0; i < a2.length; i++) { | |
if(a[a2[i]]) { | |
delete a[a2[i]]; | |
} | |
else { | |
a[a2[i]] = true; | |
} | |
} | |
for(var k in a) { | |
diff.push(k); | |
} | |
return diff; | |
} | |
/************************************************/ | |
var subsListId = []; | |
//Subscriber Initialization for all the process | |
var subscriberObj1 = Subscriber.Init(subscriberKey); | |
var subslist = subscriberObj1.Lists.Retrieve(); | |
for(var i = 0; i < subslist.length; i++) { | |
subsListId.push(subslist[i]["List"]["ID"]); | |
} | |
var correctUnsubscribedLsId = []; | |
if(correctActiveLsId.length > 0) { | |
correctUnsubscribedLsId = arrayDiff(subsListId, correctActiveLsId); | |
} | |
try { | |
if(subscriberKey) { | |
var subscriberData = { | |
"EmailAddress": email, | |
"SubscriberKey": subscriberKey | |
}; | |
if(subscribeTo) { | |
subscriberData.Status = "Active"; | |
} | |
var subObj = Subscriber.Init(subscriberKey); | |
if(unsubscribe) { | |
var unsubscribeSatus = subObj.Unsubscribe(); | |
Variable.SetValue("unsubscribeSatus", unsubscribeSatus); | |
} | |
else | |
{ | |
var udpateStatus = subObj.Upsert(subscriberData); | |
Variable.SetValue("unsubscribeSatus",(subscribeTo && udpateStatus)?"SUBSCRIBED":"NA"); | |
Variable.SetValue("udpateStatus", udpateStatus); | |
if(correctActiveLsId != 'undefined') | |
{ | |
var listSubObj = Subscriber.Init(subscriberKey); | |
for(var j = 0; j < correctActiveLsId.length; j++) { | |
var subscriberData1 = { | |
"EmailAddress": email, | |
"SubscriberKey": subscriberKey, | |
"Lists": { | |
"ID": parseInt(correctActiveLsId[j]), | |
"Status": "Active", | |
"Action": "Upsert" | |
} | |
}; | |
var status1 = listSubObj.Upsert(subscriberData1); | |
} | |
} | |
if(correctUnsubscribedLsId.length>0) | |
{ | |
var listSubObj2 = Subscriber.Init(subscriberKey); | |
for(var k = 0; k < correctUnsubscribedLsId.length; k++) { | |
if(correctUnsubscribedLsId[k]!='undefined') | |
{ | |
var subscriberData2 = { | |
"EmailAddress": email, | |
"SubscriberKey": subscriberKey, | |
"Lists": { | |
"ID":parseInt(correctUnsubscribedLsId[k]), | |
"Status": "Unsubscribed", | |
"Action": "Upsert" | |
} | |
}; | |
var status2 = listSubObj2.Upsert(subscriberData2); | |
} | |
} | |
} | |
} | |
Variable.SetValue("formSubmitted", true); | |
} | |
else { | |
Variable.SetValue("formSubmitted", false); | |
} | |
</script> | |
<center> | |
<fieldset> | |
<legend align="center"> Update Your Subscriptions | |
<br/> </legend> | |
<form method="POST"> | |
<center> | |
<img src='https://pngimage.net/wp-content/uploads/2018/05/avatar-profile-png-3.png' /> | |
</center> | |
<script runat="server"> | |
Platform.Load("core", "1"); | |
var subsKey=Variable.GetValue("@sk"); | |
var subscriberObj = Subscriber.Init(subsKey); | |
var disSubslist = subscriberObj.Lists.Retrieve(); | |
for(var i = 0; i < disSubslist.length; i++) { | |
Variable.SetValue("@listStatus", disSubslist[i]["Status"]); | |
Variable.SetValue("@listId", disSubslist[i]["List"]["ID"]); | |
Variable.SetValue("@listName", disSubslist[i]["List"]["Name"]); | |
Write("<input type='hidden' name='listName' value='" + Variable.GetValue('@listName') + "'>"); | |
disabledBlockString = ''; | |
disabledBlockString='%'+'%[IF @subscriptionStatus ==false THEN]%'+'%'+' disabled title="Please subscribe to us" '+'%'+'%[ENDIF]%'+'%'; | |
var disabledVal= Platform.Function.TreatAsContent(disabledBlockString); | |
Write("<label> " + Variable.GetValue("@listName") + "</label>"); | |
if(Variable.GetValue("@listStatus") == "Active") { | |
Write(":<input type='checkbox' name='activeListName' value='" + Variable.GetValue('@listName') + ":" + Variable.GetValue('@listId') + "' id='"+i+"' class='checkbox' checked"+disabledVal+"></input><label for='"+i+"' class='switch' style='background-repeat: no-repeat;margin-bottom: -5px;' "+disabledVal+"></label><br/>"); | |
} | |
if(Variable.GetValue("@listStatus") == "Unsubscribed") { | |
Write(":<input type='checkbox' name='activeListName' value='" + Variable.GetValue('@listName') + ":" + Variable.GetValue('@listId') + "' id='"+i+"' class='checkbox' "+disabledVal+" ></input><label for='"+i+"' class='switch' style='background-repeat: no-repeat;margin-bottom: -5px;' "+disabledVal+"></label><br/>"); | |
} | |
} | |
</script> | |
<input type="hidden" name="subscriberKey" value="%%=v(@sk)=%%"> | |
<div style="max-width:120vw;color:black;font-size:22px;text-decoration:underline"> | |
<label >%%=IIF(@subscriptionStatus, "Unsubscribe from all", "Resubscribe")=%%</label> | |
<br> | |
<input name='%%=IIF(@subscriptionStatus, "unsubscribe", "subscribe")=%%' value="true" type="checkbox" id="togglesub" class="checkbox"> | |
<label for="togglesub" class="switch" style="background-repeat: no-repeat;"></label> | |
<br>You are %%=IIF(@subscriptionStatus, "subscribed to", "unsubscribed from")=%% us!. | |
<br/> | |
</div> | |
<input type="submit" value="Update" class="raise"> | |
</form> | |
<a href="%%=RedirectTo(CloudPagesURL(552))=%%" alias="Manage Your Profile" title="Manage Your Profile">Manage Your Profile</a> | |
</fieldset> | |
</center> | |
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10.3.5/dist/sweetalert2.all.min.js"></script> | |
%%[ IF @formSubmitted AND @udpateStatus == "OK" AND @unsubscribeSatus == "NA" THEN ]%% | |
<script> | |
Swal.fire("Updated!", "Your subscription preferences are updated successfully", "success").then(() => { | |
location.href = location.href; | |
} | |
); | |
</script> | |
%%[ ELSEIF @formSubmitted AND @udpateStatus != "OK" AND @unsubscribeSatus == "NA" THEN ]%% | |
<script> | |
Swal.fire("Not Updated!", "Something went wrong while updating your preferences", "error").then(() => { | |
location.href = location.href; | |
} | |
); | |
</script> | |
%%[ ELSEIF @formSubmitted AND @unsubscribeSatus == "OK" THEN ]%% | |
<script> | |
Swal.fire("Unsubscribed!", "Sorry to see you go away!", "info").then(() => { | |
location.href = location.href; | |
} | |
); | |
</script> | |
%%[ ELSEIF @formSubmitted AND @unsubscribeSatus == "SUBSCRIBED" THEN ]%% | |
<script> | |
Swal.fire("Subscribed!", "Happy to see you again!<br/>We make sure we don't spam you!!", "success").then(() => { | |
location.href = location.href; | |
} | |
); | |
</script> | |
%%[ ELSE ]%% | |
%%[ ENDIF ]%% | |
<script runat="server"> | |
} | |
catch(ex) { | |
Write("<p style='color:red;background:black'>"+Stringify(ex)+"</p>"); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @PrafullJain the link doesn't work, but yeah I will keep All Subscriber list.
I did notice that when you opt-down from one of the publication lists it doesn't write it back to Marketing Cloud. Marketing Cloud keeps the status "active"/subscribed to the associated list. Am I missing something here?