0

I execute this LogUnsubEvent on a CloudPage and it works well.

The Subscriber get unsubscribed correctly but the value of Status don't change and remains Active on the table _Subscribers. Idk if i miss something or i have to include the value Status somewhere.

This is my code, there's some extra info because the user arrives from a preferences cloudpage and i retrieve the info from there:

    %%[var @debug var @jid var @listid var @batchid var @email var @skey var @reason var @unsubscribeAll var @id_country var @domain var @upsert var @id_language

set @debug = 0 
set @jid = AttributeValue("jobid") 
set @listid = AttributeValue("listid") 
set @batchid = AttributeValue("_JobSubscriberBatchID") 
set @email = AttributeValue("emailaddr") 
set @skey = AttributeValue("_subscriberkey") 
set @reason = RequestParameter("reason")
set @id_country = RequestParameter("id_country") 
set @domain = RequestParameter("domain")
set @id_language = RequestParameter("id_language")

if RequestParameter("submitted2") == true THEN
set @upsert = UpsertData("user_email_preferences", 1, "id_user", @skey, "reason", @reason)



/* if we know the subscriber */ 

if not empty(@skey) then

var @lue var @lue_prop var @lue_statusCode var @overallStatus var @requestId var @Response var @Status var @Error

/* if unsubscribing from all, then set the job, batch and listids to blank, effectively doing a global unsub */ 

set @jid = "" 
set @listid = "" 
set @batchid = "" 


/* create a request to inject an unsub event into the LogUnsubEvent platform table */ 

set @lue = CreateObject("ExecuteRequest") 
SetObjectProperty(@lue,"Name","LogUnsubEvent")

/* In order to invoke the request, we need to associate the following information with it to define the subscriber context and the job context:

1. Subscriber Key
2. JobId associated with the email send
3. ListID the email was sent to
4. BatchID the email was sent to
5. Reason for the unsub    */ 

/* 1. define and associate Subscriber Key to the request */ 

set @lue_prop = CreateObject("APIProperty") 
SetObjectProperty(@lue_prop, "Name", "SubscriberKey") 
SetObjectProperty(@lue_prop, "Value", @skey) 
SetObjectProperty(@lue_prop, "Name", "Status") 
SetObjectProperty(@lue_prop, "Value", "Unsub") 
AddObjectArrayItem(@lue, "Parameters", @lue_prop)

/* 2. define and associate JobID to the request */ 

if not empty(@jid) then 
set @lue_prop = CreateObject("APIProperty") 
SetObjectProperty(@lue_prop, "Name", "JobID") 
SetObjectProperty(@lue_prop, "Value", @jid) 
AddObjectArrayItem(@lue, "Parameters", @lue_prop) 

endif

/* 3. define and associate ListID to the request */ 

if not empty(@listid) then 
set @lue_prop = CreateObject("APIProperty") 
SetObjectProperty(@lue_prop, "Name", "ListID") 
SetObjectProperty(@lue_prop, "Value", @listid) 
AddObjectArrayItem(@lue, "Parameters", @lue_prop) 

endif

/* 4. define and associate BatchID to the request */ 
if not empty(@batchid) then 
set @lue_prop = CreateObject("APIProperty") 
SetObjectProperty(@lue_prop, "Name", "BatchID") 
SetObjectProperty(@lue_prop, "Value", @batchid) 
AddObjectArrayItem(@lue, "Parameters", @lue_prop) 

endif

/* 5. define and associate unsub reason to the request */ 

set @lue_prop = CreateObject("APIProperty") 
SetObjectProperty(@lue_prop, "Name", "Reason") 
SetObjectProperty(@lue_prop, "Value", @reason) 
AddObjectArrayItem(@lue, "Parameters", @lue_prop)

/* finally, you invoke the request */ 

set @lue_statusCode = InvokeExecute(@lue, @overallStatus, @requestId)

/* extract messages from the response */ 

set @Response = Row(@lue_statusCode, 1) 
set @Status = Field(@Response,"StatusMessage") 
set @Error = Field(@Response,"ErrorCode")
endif

if @debug == 1 then 
output(concat(" jid: ", @jid)) 
output(concat(" listid: ", @listid)) 
output(concat(" batchid: ", @batchid)) 
output(concat(" email: ", @email)) 
output(concat(" skey: ", @skey)) 
output(concat(" reason: ", @reason)) 
output(concat(" unsubscribeAll: ", @unsubscribeAll)) 
output(concat(" overallStatus: ", @overallStatus)) 
output(concat(" requestId: ", @requestId)) 
output(concat(" Response: ", @Response)) 
output(concat(" Status: ", @Status)) 
output(concat(" Error: ", @Error)) 


endif
endif
]%%

Thank you!

1 Answer 1

0

From the code you posted it seems that you were unsubscribing the subscribers from a specific publication list (hence the "ListID").

However, unsubscribing from a certain publication list does not mean the subscriber is unsubscribed at the subscriber level. So the data view "_Subscribers" will not reflect that correctly. Instead you can take a look at another data view called ListSubscribers where you can verify your unsub result.

You must log in to answer this question.

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