Adaptation of content (also for non-javascript)
Usercentrics basically works via Javascript. You can make a request to the frontend API to get the current consent status or use the subsequent adaptation of text/plain scripts to control the playout.
For services that do not work with Javascript or that require a placeholder as long as no consent is given, there are two possibilities:
Adjustment via the automatic attribute adjustment (Java Script bracket):
First, replacement content is provided in a DIV element:
<div id="placeholder">For example, the placeholder for a video could be here.</div>
A button for follow-up consent or other functions (see Usercentrics documentation for CMP v1 or CMP v2) can also be provided within the placeholder:
<div id="placeholder">
<p>For example, the placeholder for a video could be here.</p>
<button onclick="UC_UI.acceptService('BJz7qNsdj-7');">Accept YouTube</button>
</div>
Below the placeholder, you set a script that overwrites the placeholder with the actual content (e.g. the YouTube iFrame):
<script type="text/plain" data-usercentrics="YouTube Video">
document.getElementById('placeholder').innerHTML = '';
document.getElementById('placeholder').innerHTML += '<iframe width="560" height="315" src="https://www.youtube.com/embed/mC9i_2hLhbA" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>';
</script>
This script has been configured with the script adjustment.
Consent query via the frontend API:
Alternatively, a consent request can be made directly via the Usercentrics frontend API, which is then used to display the corresponding content:
→ Usercentrics Frontend API - CMP v1
→ Usercentrics Frontend API - CMP v2