Expand my Community achievements bar.

We are excited to introduce our latest innovation to enhance the Adobe Campaign user experience — the Adobe Campaign v8 Web User Interface!
SOLVED

JavaScript for Double Opt-in

Avatar

Level 3

Hi,

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.

1 Accepted Solution

Avatar

Correct answer by
Level 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
nms.delivery.QueueNotification("confirmation",
<delivery>
<targets>
  <deliveryTarget>
    <targetPart type='query' exclusion='false' ignoreDeleteStatus='false'>
      <where>
        <condition expr={'@id ='+ ctx.recipient.@id}/>
      </where>
    </targetPart>
  </deliveryTarget>
</targets>
</delivery>)

and adding to subscription:


// Subscribe recipient
delete ctx.recipient.visitor
var recipient=ctx.recipient
recipient.@_key="@id"
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).

View solution in original post

6 Replies

Avatar

Level 10

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.

Thanks,

Florent

Avatar

Level 3

Hi,

I had contacted Adobe Campaign support regarding JSAPI documentation and they referred to this documentation: https://docs.campaign.adobe.com/doc/AC6.1/en/CFG_API_SOAP_methods_in_JavaScript.html

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 https://docs.campaign.adobe.com/doc/AC6.1/en/WEB_Web_Forms_Use_cases.html 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?

Jae

Avatar

Level 10

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.

Florent.

Avatar

Correct answer by
Level 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
nms.delivery.QueueNotification("confirmation",
<delivery>
<targets>
  <deliveryTarget>
    <targetPart type='query' exclusion='false' ignoreDeleteStatus='false'>
      <where>
        <condition expr={'@id ='+ ctx.recipient.@id}/>
      </where>
    </targetPart>
  </deliveryTarget>
</targets>
</delivery>)

and adding to subscription:


// Subscribe recipient
delete ctx.recipient.visitor
var recipient=ctx.recipient
recipient.@_key="@id"
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).

Avatar

Level 3

Thank you so much! You're replies are much appreciated!

Jae

Avatar

Level 3

Hi vtttanhua,

Do you know where in Adobe Campaign's documentation you found this?

Thanks,

Jae