Mediavine offers a free TCF 2.0 compatible CMP in the EU for GDPR compliance with your advertising. Due to a new Google Ad Manager change, our CMP is now required to enable ad serving in the EU.

We automatically handle your consent for data related to ads for you. However, you can also use the CMP to obtain consent for non-ad related data collection by using the TCF 2.0 API.

DISCLAIMER: This requires the use of JavaScript code to implement and is intended for developer use. The TCF 2.0 API is a standard set by the IAB Tech Lab and the examples provided are only for educational purposes and not to be used directly. Use of the Mediavine CMP follows our CMP Terms of Service.

Let's get started!

How the CMP Helps You Obtain Data and Cookie Consent

First, by default, the CMP will obtain consent for Purposes 1 to 10 for you as a publisher. For a complete list of standard TCF 2.0 Purposes, see the list at the bottom of this help article.

If you have additional purposes that go beyond these, you are able to add your own custom purposes in the Mediavine Dashboard under Privacy in the Settings page.

If you're attempting to obtain permission for a third party and not your own use of data, they will have to register as a TCF 2.0 vendor. The good news is most major companies have already done so.

TCF 2.0 API

The Mediavine CMP conforms to the TCF 2.0 API. You can read the IAB Tech Lab's full documentation for more info. But in essence, what we'll be doing is using the addEventListener call in the __tcfapi function. This allows us to listen to when there is a change in consent. For example, if the user closes the modal or has previously given consent.

In addition, Mediavine provides a mediavineCmp event on the window to let you know when the TCF API is ready for use and if our CDN has determine if the user is in the EU or not. You can combine the two of these methods to wrap any of your JavaScript to only run if and when you get consent.

The Mediavine mediavineCmp event callback will have one parameter, which will be a string of either tcfApiReady when the TCF API is ready for you or gdprDoesNotApply if our CDN did not detect the user is in the EU.

Sample Code:

<script>
// Event handler that will exeute on "mediavineCmp" events
const cmpEventHandler = ({ detail }) => {
// Check if the event is for "tcfApiReady"
if (detail === 'tcfApiReady') {
// Event handler that will execute on "TCF API" events
const tcfApiEventHandler = (tcData, success) => {
// This event occurs when a user has an existing euconsent-v2 string and the CMP was not shown
const tcloaded = tcData.eventStatus === 'tcloaded';
// This event occurs whenever a user finishes interacting with the CMP
const useractioncomplete = tcData.eventStatus === 'useractioncomplete';
if (success && (tcloaded || useractioncomplete)) {
// Your code can check tcData for consent and run!

// Remove the listener now that we're done
window.__tcfapi('removeEventListener', 2, (success) => {
// If success, listener was found by CMP API and removed
}, tcData.listenerId);
} else {
// "Success" was false or neither event fired
}
}
// Register the tcfApiEventHandler function
window.__tcfapi('addEventListener', 2, tcfApiEventHandler);
}
// Check if the event is for "gdprDoesNotApply"
if (detail === 'gdprDoesNotApply') {
// GDPR does not apply, do something else
}
};
// Register the cmpEventHandler function
window.addEventListener('mediavineCmp', cmpEventHandler);
</script>

In this sample code in the section with the comment "Your code can check tcData for consent and run!" is where your code can execute. You should check the tcData for consent to the purpose you're using in either the publisher or the vendor. For example, check for Purpose 1 before you store data or Purpose 8 before you measure your analytics.

To learn the format of tcData, we recommend checking the TCData section of the API documentation. If you're obtain the consent, you'll want to look under tcData.publisher.

Limited Support

It's important to note that Mediavine will not be able to help you with implementing the TCF 2.0 API on your site. However, if you run into issues with our CMP lacking a feature or properly implementing the TCF 2.0 API, please contact us right away.

List of standard TCF 2.0 Purposes:

  1. Purpose 1 = Store and/or access information on a device
  2. Purpose 2 = Select basic ads
  3. Purpose 3 = create a personalized ad profile
  4. Purpose 4 = Select personalized ads
  5. Purpose 5 = Create a personalized content profile
  6. Purpose 6 = Select personalized content
  7. Purpose 7 = Measure ad performance
  8. Purpose 8 = Measure content performance
  9. Purpose 9 = Apply market research to generate audience insights
  10. Purpose 10 = Develop and improve products

Did this answer your question?