Skip to main content
DmytroPanchenk
Level 3
Jul 18, 2024 2:40 AM UTC
Solved

Setting Nonce for experiences containing Javascript in Adobe Target

Hi Everyone,

I am currently integrating Adobe Target into a site that uses Content Security Policy (CSP) headers with nonce values for third-party and inline scripts:

Content-Security-Policy: script-src 'nonce-<value>'

I am using Adobe Launch to load Target. Adobe Launch supports nonce and successfully loads Target along with other extensions and rules.

However, I am encountering an issue with Javascript in the Target experiences. These experiences are based on Target Experience Templates (https://github.com/Adobe-Marketing-Cloud/target-experience-templates) that is, consist of a <script> element with Javascript inside. It appears that Target does not insert the nonce when placing the script on the page.

Is there a way to instruct Adobe Target to specify the nonce when inserting Javascript experiences?

Any guidance would be greatly appreciated.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
DmytroPanchenk
DmytroPanchenkAccepted solution
Level 3
Jul 18, 2024 7:50 PM UTC

Ok, it turned out that I just needed to set cspScriptNonce in targetGlobalSettings.

 

const nonce = <getting-the-nonce-value>; window.targetGlobalSettings = { . . . cspScriptNonce: nonce };

 

4 replies

DmytroPanchenk
DmytroPanchenkAuthorAccepted solution
Level 3
Jul 18, 2024 7:50 PM UTC

Ok, it turned out that I just needed to set cspScriptNonce in targetGlobalSettings.

 

const nonce = <getting-the-nonce-value>; window.targetGlobalSettings = { . . . cspScriptNonce: nonce };

 

Translate
Gokul_Agiwal
Community Advisor
Community Advisor
Jul 19, 2024 9:01 AM UTC

Hi @dmytropanchenk Good to know it's worked out for you. 

yes, this is the right config for CSP nonces to be added into Script under targetGlobalSetting,  

https://experienceleague.adobe.com/en/docs/target-dev/developer/client-side/at-js-implementation/functions-overview/targetglobalsettings#content-security-policy

Translate
Thanks, Gokul
Adobe Employee
Apr 17, 2025 6:44 AM UTC

Hi @Dmytro_Panchenk , @gokul_agiwal ,

 

I am facing similar issue and my Target version is < 2.2.0+  . Any Idea what needs to be done fox fixing this nonce issue ?                                                                                                                                                      Thanks,

Surendra

 

Translate