iFrames can be rewritten in a manner similar to the JavaScript method.
To Implement iFrame Rewriting
Given the typical iFrame:
<iframe src="https://www.youtube.com/yourvideo"></iframe>
-
Change src
attribute to data-src
.
-
Add class="optanon-category-[Category ID]"
with [CategoryID] replaced with the appropriate cookie category ID for the iFrame.
The end result will be:
<iframe data-src="https://www.youtube.com/yourvideo" class="optanon-category-[Cookie ID]"></iframe>
The OneTrust script will now rewrite this iFrame to the correct src
attribute and will only load the iFrame after consent is given.
To find your Cookie Category IDs, see Finding the Cookie Group IDs.