0

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:

  1. Save the form data in MC DE - (This part is Working and completed)
  2. 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
]%%

1 Answer 1

0

I’d try adding a redirect once everything is processed in SFMC, something like this:

…
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

Redirect(@encparam_encode) /* add redirect here so that it goes from here to another page once the unsub is succesfully captured in MC */

ELSE
Output(v('<font color="#ffffff">Contact not updated.</font><br>'))
   
ENDIF
]%%

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .