0

we created a custom unsubscribe page using the AMPscript and html/css combination. We have 3 consent types: (general) OptIn, OptIn_Products, and OptIn_Services. All 3 are type boolean. Now, since it's an unsubscribe page, we only have one form field - OptIn. After subscriber clicks on this option, this gets passed on to the confirmation page where all the back-end processing with AMPscript is done. This works well. However, we would like to add in the final UpdateDE AMPscript's arguments the 2 other consent lines, meaning, although not specifically mentioned, the 2 optins (products and services) would also get boolean: false in the target DE. When I tried to add this into updateDE (i.e. hard-code the boolean updates), the page stops working. Here's the code from second, processing page relevant to this case:

SET @rowsMaster=LookupRows("Master_Contacts","Contact_Key", @ContactKey)
IF RowCount(@rowsMaster)>0 THEN
SET @rowMaster=Row(@rowsMaster,1)
SET @Email=Field(@rowMaster,"Email_Address")
ENDIF

SET @ll_sub = CreateObject("Subscriber")

SetObjectProperty(@ll_sub,"EmailAddress", @Email)
SetObjectProperty(@ll_sub,"SubscriberKey", @ContactKey)

SET @client = CreateObject("ClientID")
SetObjectProperty(@client, "ID", BU-Id left blank on purpose)
SetObjectProperty(@client, "IDSpecified", "true")
SetObjectProperty(@ll_sub, "Client", @client)

Set @options = CreateObject("UpdateOptions")
Set @save = CreateObject("SaveOption")
SetObjectProperty(@save,"SaveAction","UpdateAdd")
SetObjectProperty(@save,"PropertyName","Status")
AddObjectArrayItem(@options,"SaveOptions", @save)

IF @checkboxO=="Optout" THEN
SET @checkboxO=0

SetObjectProperty(@ll_sub,"Status", "Unsubscribed")

SET @prodCheck=0
SET @servCheck=0
ENDIF


VAR @updateStatusMessage, @updateErrorCode, @updateOptions

SET @updateStatusCode = InvokeUpdate(@ll_sub, @updateStatusMessage, @updateErrorCode, @options)

updateDE("Master_Permission",1,"Contact_Key", @ContactKey, "OptIn",@checkboxO,"OptIn_Products",@prodCheck,"OptIn_Services",@servCheck)

]%%
1

1 Answer 1

0

You're declaring your two hard-coded variables inside an IF statement block, so they'll not have scope outside of the block. Either explicitly declare the two variables at the top of the page or move your implicit declarations using SET outside of the conditional block.

Also, for what you're doing here, you'd normally want to do a LogUnsubEvent, rather than just update the Subscriber object. You'll have no reporting on the number of unsubscribes generated by your email campaigns when you're simply doing Subscriber updates.

2
  • Thanks Macca. Clear about tge scope. As for logUnsubEvent, I've ne ever actually used it, but will it also unsubscribe a person from All Subscribers list, along with creating an unsubscribe report?
    – nix9247
    Commented Feb 25, 2020 at 5:37
  • Yes. The LogUnsubEvent call updates the Subscriber record's status to "Unsubscribed" for you as well as generating an unsubscribe event for reporting purposes.
    – Macca
    Commented Feb 25, 2020 at 20:08

You must log in to answer this question.

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