Salesforce

Manually Rewriting iFrames in Cookie Consent

« Go Back
Information
Manually Rewriting iFrames in Cookie Consent
UUID-3dc06342-ff6b-3578-5024-6d7c05d03283
Article Content

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>
  1. Change src attribute to data-src.

  2. 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.

To Implement iFrame Rewriting when using Vendor Identification

Note

Vendor Identification, Categorization, and Consent is currently under Public Preview. Please contact your account representative or OneTrust Support to request access.

When endor Identification, Categorization, and Consent is enabled, tag rewriting logic considers the Service ID instead of category ID.

Given the typical iFrame:

<iframe src="https://www.youtube.com/yourvideo"></iframe> 
  1. Change the src attribute to data-src.

  2. Add class="ot-vscat-[Service ID]", replacing [ServiceID] with the appropriate cookie category ID for the iFrame.

The end result displays as follows:

<iframe data-src="https://www.youtube.com/yourvideo" class="ot-vscat-[Service 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 this specific service.

 
Article Visibility
35,725
Translation
English
Checked

Powered by