Blocking YouTube videos
Prevent YouTube from loading before consent is obtained
YouTube videos embedded using an iframe can be configured so that external content does not load until the visitor has authorised the corresponding category in Alamarte Cookie Consent Pro.
src with data-acc-src.
While the video address remains in data-acc-src, the browser will not load it as a normal iframe. Alamarte Cookie Consent Pro can activate it when consent exists for the category specified using data-acc-category.
Normal YouTube iframe
The code normally provided by YouTube contains the video address directly in the src attribute:
<iframe
width="560"
height="315"
src="https://www.youtube.com/embed/VIDEO_ID"
title="YouTube video"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowfullscreen>
</iframe>
In this form, the browser can load YouTube content immediately when the page opens.
Iframe prepared for Alamarte Cookie Consent Pro
To keep the video blocked until the visitor authorises the Marketing category, use the following format:
<iframe
width="560"
height="315"
data-acc-category="marketing"
data-acc-src="https://www.youtube.com/embed/VIDEO_ID"
title="YouTube video"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowfullscreen>
</iframe>
Replace VIDEO_ID with the actual identifier of the video you want to display.
1. Keep the iframe code
You can keep the dimensions, title, permissions and other attributes provided by YouTube.
The required change mainly affects how the video address is defined and which consent category is assigned.
2. Remove src
Do not leave the video address inside src, because the browser may load YouTube before Alamarte Cookie Consent Pro can apply consent.
Use only data-acc-src for the address that should remain pending.
3. Add the category
Add data-acc-category="marketing" to indicate that the video depends on authorisation of the Marketing category.
The category used should match the classification you have defined for that service on your site.
4. Save and review the code
After saving the article or module, review the content code again.
Check that data-acc-category and data-acc-src are still present and that the editor has not automatically restored the src attribute.
Do not use src and data-acc-src at the same time
For a video that should remain blocked, do not use this combination:
<iframe
src="https://www.youtube.com/embed/VIDEO_ID"
data-acc-src="https://www.youtube.com/embed/VIDEO_ID"
data-acc-category="marketing">
</iframe>
If src contains the actual video address, the browser may start loading it independently of data-acc-src.
If you use JCE
When editing content with JCE or another editor, check that the custom data-* attributes are not removed when saving.
After saving, open the code again and confirm that the Alamarte Cookie Consent Pro attributes remain intact.
Test without previous consent
Open the page in a private or incognito window to test it as a visitor who has not yet saved any preferences.
First check the behaviour without authorising Marketing, then accept the category to confirm that the video can be activated.
The same principle applies to other external iframes: keep the pending address in data-acc-src, specify the category using data-acc-category and avoid keeping the actual address in src at the same time. For other cases, see Google Maps and other external iframes.

ES
EN



