JavaScript for Double Opt-in




We are creating a "double opt-in" email confirmation process for our European subscribers (Europeans who subscribe to our newsletters are required by European law to confirm their subscription through a follow-up confirmation email).

We created a web form with a form field, "Country," and if any European residence selects a European country of residence in the form field, then an automated confirmation email is sent to confirm their subscription; for anyone outside the European union (in the US, for example), they are subscribed to our newsletters (without a confirmation [double opt-in] email process).

Can anyone helps us with the JavaScript code that's required for the following Adobe Campaign "double opt-in" workflow:

enter image description here

...for JavaScripts, "Trigger Double Opt-in in Email," and "Subscribe to the service."

Can anyone help us with the JavaScript or help us get going?

Thank you.

Accepted Solutions (1)

Accepted Solutions (1)



AC has out of the box web application sub that can be used as a base for this.


In 'send confirmation' JS you can find code for sending confirmation email and adding recipient to subscription:


// Send confirmation"confirmation",
    <targetPart type='query' exclusion='false' ignoreDeleteStatus='false'>
        <condition expr={'@id ='+ ctx.recipient.@id}/>

and adding to subscription:

// Subscribe recipient
delete ctx.recipient.visitor
var recipient=ctx.recipient
delete recipient.@blackList_init
delete recipient.@xtkschema
nms.subscription.Subscribe(ctx.vars.serviceName, recipient, false)


Sending confirmation should in your case be made conditional (and then not setting recipient to blacklisted).

Answers (5)

Answers (5)



Hi Jae,

Yes the JSAPI documentation I am referring to is a CHM document that references all functions that can be used.

Considering your specific requirements I don't know what the best solution is. JS can indeed be used if you have the proper knowledge. Otherwise I assume that Adobe Professional Services could implement a custom solution for this.

Let me know if you have additional questions when you get access to the JSAPI document.





I had contacted Adobe Campaign support regarding JSAPI documentation and they referred to this documentation:

I am assuming this is different than what you are referring to as JSAPI documentation.

If so, then I will contact support again to see if we have access to APIs and JSAPI documentation.

Yes, I had a chance to peruse for Double Opt-in implementation, but we are also developing customized double opt-in option, where our forms contain the field, "Country," and should any European subscribers select a European country as their residence, we need to trigger an automated double opt-in email confirmation process, whereas should anyone outside of Europe select an non-European country of residence (like the United States, for example), they would not be sent a double opt-in confirmation email. Hence, the two JavaScript activity.

Would you still recommend a non-JS activity in light of this?




Hi Jae,

I will try to look for examples. Do you have access to the JSAPI documentation?

Do you still need this information or did you fin another way of doing it?

I'd recommend to have a look at this double opt-in example to see if you have a way to avoid using JS activities.