When someone clicks on the email unsub URL, it will be redirected to the cloud page, and on CP, there are reasons for unsub using the check box. I want to perform two actions on a single button:
- Save the form data in MC DE - (This part is Working and completed)
- Unsub with a custom URL
I created the processing page, where the main form data is collected and saved in DE but not able to understand how should i add the unsub functionality. @encparam_encode is the variable used to unsub and thank you page which should be display
SET @Id = _subscriberkey
set @answer1 = Iif(RequestParameter("answer1") == "on", "true", "false")
set @answer2 = Iif(RequestParameter("answer2") == "on", "true", "false")
set @answer3 = Iif(RequestParameter("answer3") == "on", "true", "false")
set @submitted = RequestParameter("submitted")
IF RequestParameter("submitted") == "Submit" THEN
**
set @key= @Id
set @encparam= EncryptSymmetric(@key, 'AES', 'optout_secret', @null, 'optout_salt', @null, 'optout_iv', @null)
set @encparam_encode = URLEncode(@encparam,1,1)
set @encparam_encode = Concat('https://xyz.com/channelprefcenter?e=',@encparam_encode)
**
set @rows = LookupRows("Unsub_Answer_LP", "ID", @ID)
set @rowCount = rowcount(@rows)
if @rowCount > 0 then
set @row = row(@rows,1) /* just get row #1 */
UpsertDE('Unsub_Answer_LP',1,'ID',@ID, 'answer1', @answer1,'answer2', @answer2,'answer3', @answer3 )
else
InsertDE('Unsub_Answer_LP','ID',@ID, 'answer1', @answer1,'answer2', @answer2,'answer3', @answer3)
endif
ELSE
Output(v('<font color="#ffffff">Contact not updated.</font><br>'))
ENDIF
]%%