no-click unsubscribe web app code explanation | Community
Skip to main content
Marcel_Szimonisz
Community Advisor
Community Advisor
May 21, 2024
Question

no-click unsubscribe web app code explanation

  • May 21, 2024
  • 1 reply
  • 1165 views

Hello I have some questions regarding the new deliverability good practice 
https://experienceleague.adobe.com/en/docs/deliverability-learn/deliverability-best-practice-guide/additional-resources/campaign/acc-technical-recommendations

I have loaded the code mentioned on the page above.

 

  • Can somebody explain where the ctx.@secret is created and how I set ctx.@_method? It is supposed to be POST based on the article. I could not find any specific settings on properties of the web app not we do not add except recipient id anything to the no-click unsub link.

 

 

 

 

if (NL.isEmpty(ctx.@secret)) logError("invalid secret..."); var secret = decryptString(ctx.@secret); if (NL.isEmpty(secret)) logError("invalid secret..."); this.secret = JSON.parse(secret); if (NL.isEmpty(this.secret)) logError("invalid secret..."); if (this.secret.method != ctx.@_method || this.secret.identifier != ctx.@_identifier || this.secret.key != ctx.recipient.@_key ) { logError("invalid secret..."); } if( String(ctx.recipient.@id) != decryptString(this.secret.identifier) ) logError("The webApp inputs are corrupted."); // remove descenants @_key to protecte against sql injection var descendantNode = ctx.recipient.descendants(); for (var i = 0; i < descendantNode.length(); i++) { delete descendantNode[i].@_key; delete descendantNode[i].@_operation; } nms.subscription.Unsubscribe(ctx.vars.service, ctx.recipient)

 

Kind regards,

Marcel

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

Parvesh_Parmar
Community Advisor
Community Advisor
May 21, 2024

Hello @marcel_szimonisz ,

 

I've downloaded the package and installed it on the local server. Here's what I found:

  1. Web App Overview: The web app appears to have three main activities: Preloading, Script, and End Activity.

  2. App URL: The URL for the app is:

    https://adobesandboxServerURL.com/webApp/unsubNoClick?id=<%= escapeUrl(cryptString(recipient.id)) %>
    
  3. API Call and Variable Creation: When you call this API, the Preloading activity creates a CTX variable named ctx.@secret. This variable is based on the encrypted recipient ID and stores an array of values. It then passes this variable to the next Script activity.This contains the recipient full information which is use in the script activity.

Hope it will help.

Thanks,

Parvesh

 

 

Parvesh Parmar – Adobe Community Advisor https://www.linkedin.com/in/parvesh-parmar/
Marcel_Szimonisz
Community Advisor
Community Advisor
May 22, 2024

Hello @parvesh_parmarm,

thanks for your time spent on this. For me its kind of a mistery. Why the secret ctx is created in preloading, what is in there? what is ctx._method?
I could not find it anywhere set.


Marcel

Parvesh_Parmar
Community Advisor
Community Advisor
May 22, 2024

Hello @marcel_szimonisz ,

 

If you run this webapp in debug mode, you could check the value:

 

PFA: Screenshot

 

CTX Data: There you can find all the variables. 

 

<ctx _console="1" lang="en" score="0" date="2024-05-22T11:30:26Z" _target="web" webApp-id="17921" origin="neolane" _folderModel="nmsRecipient" _identifier="@LBixjPbMZSptbFtzQegCcA==" _method="encryptedId" secret="@/2smQF+ypWCnYdIgQZEkwekKsLiH4TWkj6Z6WTli0oet+udV70f8SywwmE3hpUNTL4dJ/Dfidr9MwhZ6y9m+pbX9CcyMy2lCReZVyLgK+64ykkM0N/s5/TS/PKvwM2omHLL9PJg7h1N7kgS+SfRWqbufXC0D2yHgsIq/hm1wC00=" activityHist="@GuYcHLU8/iMaCBBS60D1+lv157nxFv0byINt7MA0DWbgnYPI33K9FhcdeRBdgPARBykP1CV0UWbwmqx4gEANjP4ukH3pntT2HePhDvlxeWZJbOhEO0TfdZjS7pZphUgI6byKGllUGEwiGoba7QMzdk+Z9kMEvpdYzccRnEyDTCXpKz+62Rzoqt0g40VrQVJC5zhK2/1D+u1bESgggq6Dup7iQA72ZC6/D5L8dE4142c=">
<userInfo datakitInDatabase="true" homeDir="" instanceLocale="en-GB" locale="en-GB" login="webapp" loginCS="Web applications agent (webapp)" loginId="1598" noConsoleCnx="true" orgUnitId="0" theme="" timezone="Europe/Paris" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="urn:xtk:session" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<login-right right="webapp"/>
</userInfo>
<timezone current="Europe/Paris" changed="false"/>
<recipient id="1002" _operation="update" _key="@id"/>
<activityHistory>
<activity name="end" type="end"/>
<activity name="script" type="script"/>
<activity name="prefill" type="prefill"/>
</activityHistory>
</ctx>

 

 

As you can check  ctx._method="encryptedId"

 

I don't think Adobe will explain how they calculate these values within the preloading activity.

Here, you can check this CTX data. If you want to modify these values or add new variables, you can easily do so.

 

 

Kr,

Parvesh

 

Parvesh Parmar – Adobe Community Advisor https://www.linkedin.com/in/parvesh-parmar/