Secure Privacy

How to Set Up Contextual Consent in Secure Privacy: Templates, sp-consent Attribute & GDPR Compliance

Learn how to configure Secure Privacy's Contextual Consent feature — customize your overlay template, add the sp-consent attribute to iframe and image elements, and ensure GDPR-compliant consent for embedded third-party content.

SPT
Secure Privacy Team
6 min read ()

Summary: Contextual consent gives users a fair, transparent way to understand and agree to the specific use of their personal data before content such as embedded videos, maps, or iframes is loaded. This guide walks through how to set up and customize a Contextual Consent page in Secure Privacy using the Templates feature — including enabling the feature, configuring message and button text, previewing across devices, and implementing the sp-consent attribute on your page.

Who Is This Guide For?

  • Website administrators managing GDPR and CCPA-compliant consent flows for embedded content
  • Developers implementing the sp-consent attribute on img or iframe elements
  • Marketers and compliance managers customizing contextual consent messaging and button text to reflect their brand

Secure Privacy's three-way preview simulates how your contextual consent overlay appears across different device types — desktop, tablet, and mobile. Note that the preview is an approximate indicator; for the most accurate representation, switch to full-screen view to see the page exactly as your users will.

Click the EDIT button at any time to switch to editing mode, where you can adjust text, button labels, and settings. This flexibility ensures your contextual consent page always accurately reflects your brand values and privacy commitment.

Secure Privacy contextual consent page preview showing desktop, tablet, and mobile views with the Edit button highlighted
Use the three-way preview to check your contextual consent overlay across device sizes, then switch to full-screen for the most accurate view.

Language Settings

All Secure Privacy templates are preconfigured and pre-translated, giving users a localized consent experience out of the box. To add or remove a supported language, navigate to Templates > Settings.

Under Text in the Message Settings panel, you can fully customize the copy displayed on your contextual consent overlay. Write clear, concise, and informative text that explains what data is being shared and why — reinforcing your brand's commitment to data transparency and user privacy.

Button Text: Call-to-Action Labels

Button text controls the labels shown on each consent action button — such as "Accept," "Decline," or "Learn More." These labels should be direct and action-oriented, clearly communicating what each choice means for the user's data. Under GDPR, consent and refusal options must be equally prominent and unambiguous.

Secure Privacy contextual consent message settings and button text customization panel in the template editor
Customize your consent overlay message text and button labels in the Message Settings panel.

To activate contextual consent blocking on a specific embedded element, add the sp-consent attribute to any <img> or <iframe> tag on your page. This tells Secure Privacy to intercept that element and display the contextual consent overlay until the user grants permission.

Example — blocking an iframe (e.g., a YouTube embed):

<iframe
  src="https://www.youtube.com/embed/your-video-id"
  sp-consent
  width="560"
  height="315"
  frameborder="0"
  allowfullscreen>
</iframe>

Example — blocking an image pixel:

<img src="https://example.com/tracking-pixel.png" sp-consent />

Important: The sp-consent attribute is required on every element you want contextual consent to govern. Do not skip this step — without it, the element will load without triggering the consent overlay.

Frequently Asked Questions (FAQ)

A cookie banner asks for broad consent when a user first visits your site. Contextual consent works differently — it blocks specific embedded elements (like videos or maps) from loading and displays a targeted consent prompt directly where that content would appear. This gives users granular, in-context control over individual data-sharing events, which is particularly important under GDPR for third-party embeds.

The sp-consent attribute can be added to any <img> or <iframe> element on your page. Common use cases include YouTube or Vimeo video embeds, Google Maps iframes, social media widgets, and third-party tracking pixels.

Do I need to classify my iframe and img elements in Domain Settings?

Yes. After adding sp-consent to your tags, you must ensure the corresponding elements are correctly categorized under Domain Settings > Classification. Without proper classification, the contextual consent overlay may not trigger for the correct consent category.

Yes. Within Templates > Contextual Consent, you can customize the overlay message text, button labels, and language settings. You can also apply custom CSS for further visual alignment with your brand identity.

Contextual consent is not explicitly mandated by name under GDPR, but the regulation does require that personal data is only shared with third parties after specific, informed, and active user consent. Embedding third-party content that loads tracking scripts without prior consent can constitute a GDPR violation. Contextual consent is a recognized best-practice mechanism for achieving compliance with this requirement.

Conclusion

Secure Privacy's Contextual Consent feature gives you a powerful, brand-customizable way to manage user consent for embedded third-party content — helping you meet GDPR and CCPA obligations while keeping the user experience transparent and friction-free. By enabling the feature in your template, adding the sp-consent attribute to the right elements, and classifying them correctly, you can deploy a fully compliant contextual consent flow with minimal development effort.

Need more help?

Our privacy experts are here to guide you through complex regulations and find the right solution.

Contact Support

Related Articles

View all