-
Notifications
You must be signed in to change notification settings - Fork 0
/
sfmc_prefcenter_tonyzups
102 lines (84 loc) · 5.46 KB
/
sfmc_prefcenter_tonyzups
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><META http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body><div>
<div>
<label>
<input type="radio" name="option" value="Option1" checked>
Option1
</label>
</div>
<div>
<label>
<input type="radio" name="option" value="Option2">
Option2
</label>
</div>
<div>
<label>
<input type="radio" name="option" value="Option1">
Option3
</label>
</div>
</div>
set your form method to post and action to your form handler/thankyou cloud page
On that page you would set the ampscript as follows:
set @option = RequestParameter('option')
if @option == "Option1" then
set @chosen = "option 1 value"
elseif @option == "Option2" then
set @chosen = "option 2 value"
etc
so that captures the option based off of the form input `name` value and sets it to whatever the value is.
Then you use an upsertData function to take the input and push it into a DE to hold the preferences
<a href="https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-programmatic-content.meta/mc-programmatic-content/upsertdata.htm?search_text=upsertData" target="_blank">https://developer.salesforce.<wbr>com/docs/atlas.en-us.<wbr>noversion.mc-programmatic-<wbr>content.meta/mc-programmatic-<wbr>content/upsertdata.htm?search_<wbr>text=upsertData</a>
Then from there you can filter the resulting DE for the user preferences.
does that make sense?
so then the form handler ends up looking like this
VAR @PreferenceRows,@<wbr>SubscriberRows
/*SET @SubscriberID = RequestParameter('sid')*/
SET @SubscriberKey = RequestParameter('sk')
SET @JobID = RequestParameter('j')
SET @options = RequestParameter('opt')
SET @SubscriberRows = LookupRows('Preferences','<wbr>SubscriberKey',@SubscriberKey)
IF RowCount(@SubscriberRows) > 0 THEN
SET @r = ROW(@SubscriberRows,1)
SET @EmailAddress = Field(@r, 'EmailAddress')
IF @options == 1 THEN
UpsertData('Preferences',1,'<wbr>SubscriberKey',@SubscriberKey,<wbr>'EmailAddress',@EmailAddress,'<wbr>AllNews',1,'90Day',0,'90DayTS'<wbr>,null,'Monthly',0,'Christmas',<wbr>0,'Unsubscribe',0)
ELSEIF @options == 2 THEN
UpsertData('Preferences',1,'<wbr>SubscriberKey',@SubscriberKey,<wbr>'EmailAddress',@EmailAddress,'<wbr>AllNews',0,'90Day',1,'90DayTS'<wbr>,NOW(),'Monthly',0,'Christmas'<wbr>,0,'Unsubscribe',0)
ELSEIF @options == 3 THEN
UpsertData('Preferences',1,'<wbr>SubscriberKey',@SubscriberKey,<wbr>'EmailAddress',@EmailAddress,'<wbr>AllNews',0,'90Day',0,'90DayTS'<wbr>,null,'Monthly',1,'Christmas',<wbr>0,'Unsubscribe',0)
ELSEIF @options == 4 THEN
UpsertData('Preferences',1,'<wbr>SubscriberKey',@SubscriberKey,<wbr>'EmailAddress',@EmailAddress,'<wbr>AllNews',0,'90Day',0,'90DayTS'<wbr>,null,'Monthly',0,'Christmas',<wbr>1,'Unsubscribe',0)
ELSEIF @options == 5 THEN
UpsertData('Preferences',1,'<wbr>SubscriberKey',@SubscriberKey,<wbr>'EmailAddress',@EmailAddress,'<wbr>AllNews',0,'90Day',0,'90DayTS'<wbr>,null,'Monthly',0,'Christmas',<wbr>0,'Unsubscribe',1)
ENDIF
IF @options == 5 THEN
SET @lue = CreateObject("ExecuteRequest")
SetObjectProperty(@lue,"Name",<wbr>"LogUnsubEvent")
SET @lue_prop = CreateObject("APIProperty")
SetObjectProperty(@lue_prop, "Name", "SubscriberKey")
SetObjectProperty(@lue_prop, "Value", @SubscriberKey)
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", "Reason")
SetObjectProperty(@lue_prop, "Value", "Unsubscribed from Custom Preference Center")
AddObjectArrayItem(@lue, "Parameters", @lue_prop)
SET @resp = InvokeExecute(@lue, @overallStatus, @requestId)
SET @Response = Row(@resp, 1)
SET @Status = Field(@Response,"<wbr>StatusMessage")
SET @Error = Field(@Response,"ErrorCode")
ELSE
SET @Subscriber = CreateObject("Subscriber")
SetObjectProperty(@Subscriber, "SubscriberKey",@<wbr>SubscriberKey)
SetObjectProperty(@Subscriber, "EmailAddress",@EmailAddress)
SetObjectProperty(@Subscriber, "Status", "Active")
SET @resp = InvokeUpdate(@Subscriber, @createErrDesc, @createErrNo, @createOpts)
ENDIF
ENDIF
]%%
The extra ampscript in there is standard to log the unsubscribe event, and the script at the bottom only runs if unsubscribe (option 5) is chosen and changes the status.
</body></html>