/
Script-Adjustment (Javascript only)

Script-Adjustment (Javascript only)

The simplest method to prevent Javascript from executing without Consent is a small adjustment, so that the browser no longer interprets the script as such:

In the scripts, the type must be changed from type="text/javascript" to type="text/plain". If the type "text/javascript" is not explicitly stated in the script because it can also be interpreted by the browser without being stated, "text/plain" must still be added.

Usercentrics can recognise these scripts with the help of an attribute and, if consent is given, set the type from text/plain back to text/javascript. For a correct mapping, a "data attribute" must therefore also be added:

This data attribute is structured according to the following principle: data-usercentrics="[Consentname]", where "Consentname" is the exact name of the data processing service created in the Usercentrics Admin Interface under "Service Settings". Alternatively, the name can also be copied directly from the CMP settings Modal.

Attention: Upper & lower case are considered, as well as spaces!

 

Example:

An example using the Google Analytics script:

Original:

<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXX"></script> <script>   window.dataLayer = window.dataLayer || [];   function gtag(){dataLayer.push(arguments);}   gtag('js', new Date());     gtag('config', 'UA-XXXXXXXX-X'); </script>

 

Adjusted:

<script type="text/plain" data-usercentrics="Google Analytics" async src="https://www.googletagmanager.com/gtag/js?id=UA-XXX"></script> <script type="text/plain" data-usercentrics="Google Analytics">   window.dataLayer = window.dataLayer || [];   function gtag(){dataLayer.push(arguments);}   gtag('js', new Date());     gtag('config', 'UA-XXXXXXXX-X'); </script>

 

 

Note: This method works for both CMP v1 and CMP v2.

Related content