Ads & revenue · Demo 6 of 6

Consent that reaches the ad inside the Riddle

Your consent manager knows whether a reader allows personalised ads. One data layer push and a small handshake carry that choice two frames deep, to the Google Ad Manager tag inside the Riddle.

Riddle features: data layer + project ad slot

Setup: about 30 minutes

Works with any consent manager

Live Riddle

Quiz · 2 questions + ad

[[dg-consent]]

[[dg-riddle qM7k3eK6 h=640]]

Answer the first question to reach the ad. Decide in the banner, then use “Change my choice” and play again: the ad follows your choice.

[[dg-inspector]]

Why it takes two steps

The ad sits two frames away from your consent manager.

Only your page knows the reader's choice. The Riddle is a frame from riddle.com, and the ad tag runs in another frame inside it. Neither can read your cookies or call your consent manager, so the choice has to be handed in.

your-site.com

Your consent manager lives here and knows the choice. The page pushes it into the data layer and answers the ad's question.

Riddle frame · riddle.com

Forwards every data layer change into the ad frame as an isRiddleDataLayerEvent.

Ad frame · your ad tag

Waits for the choice, sets the Ad Manager key consent = granted or denied, then requests the ad.

What just happened

Your choice, handed in twice.

01

The consent manager decides

When the reader accepts or rejects, the page pushes consent = granted or denied into the Riddle data layer.

02

The ad frame asks

As it loads, the ad tag sends riddleConsentRequest to the page and gets the current value back. Without an answer it waits 500 ms, then uses denied.

03

Ad Manager picks the ad

The tag sets the key consent and requests the ad. A later change arrives through the data layer and refreshes the slot.

Build it yourself

The page code and the settings.

1 · On your page

Hook your consent manager to one push, and answer the ad frame's question. This example uses the IAB TCF API; OneTrust, Cookiebot and Usercentrics work the same way.

window.riddleDataLayer = window.riddleDataLayer || [];

function pushConsent(value) { // 'granted' or 'denied'
  window.riddleDataLayer.push({ key: 'consent', value: value });
}

// IAB TCF v2: purposes 1 and 3 cover personalised ads
__tcfapi('addEventListener', 2, function (tcData, ok) {
  if (!ok) return;
  var p = tcData.purpose.consents;
  pushConsent(p[1] && p[3] ? 'granted' : 'denied');
});

// answer the ad frame inside the Riddle
window.addEventListener('message', function (e) {
  if (e.origin !== 'https://www.riddle.com') return;
  if (!e.data || e.data.type !== 'riddleConsentRequest') return;
  var last = window.riddleDataLayer.filter(function (i) {
    return i.key === 'consent'; }).pop();
  e.source.postMessage({ type: 'riddleConsentReply',
    consent: last ? last.value : 'denied' }, 'https://www.riddle.com');
});

2 · In Riddle and Ad Manager

Set up once per project; every Riddle can then use the slot.

  1. Riddle → Publish → Data layer: add the key consent.
  2. Project → Ad slots: paste the consent-aware ad tag from Riddle's example into a slot, with your ad unit and size.
  3. Riddle: add an Ad block (or a display ad) that uses this slot.
  4. Ad Manager: create the key-value consent with granted and denied, and target one line item to each.

Privacy & compliance

Denied until the reader decides.

  • Only the word granted or denied crosses the frames; no cookies, IDs or personal data.
  • The ad frame asks from https://www.riddle.com, so check that origin and reply to it exactly.
  • Until the consent manager has an answer, the page replies denied, and the tag falls back to denied after 500 ms.
  • A later change reaches the ad at once. Riddle reads data layer values for its own text when it starts, so this demo restarts the Riddle after a new choice.
  • The banner on this page simulates a consent manager. On your site your real CMP calls the same push.

Next track · Login & personalization

Know your reader inside the Riddle

Open the login demos →
Scroll to Top