Ads - Consent Management (CM - CMP)

> Marketing > Advertising

1 - About

Consent Management is a mandatory privacy process due to gdpr where a website showing a page to a EU resident needs the consent of the user in order to use their data (cookies,..)

Advertising

The consent box may ask you to define the type of cookie usage that the user could accept.

3.1 - Necessary

You cannot use the web site (web application without this cookies).

3.2 - Preferences

Preference cookies enable a website to remember information that changes the way the website behaves or looks, like your preferred language or the region that you are in.

3.3 - Statistic

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

3.4 - Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

3.5 - Unknown

All other cookie category are unknown cookie type.

4 - Implementation

You can implement it:

Advertising

4.1 - Self

4.1.1 - Javascript

Example with:

// The storage key
let consentKey = 'consentValue';
// The value of the consent if the user is not from a EU country
let consentValueNonEu = 'NonEu';
// Do we have already a consent ?
let consentStorage = localStorage.getItem(consentKey);
if (!consentStorage) {
	localStorage.setItem(consentKey, false);
}
 
// Do we need to show the consent box
// localStorage.getItem return a string, therefore !'false' is false and not true ---
let consent = ( consentStorage !== 'true' || consentStorage !== consentValueNonEu);
if (consent) {
       // Country
	jQuery.ajax(
		'https://ip2c.org/self',
		{
			success: function (data) {
				let countryCode = data.split(";")[1];
				let euCountryCodes = ['AL', 'AD', 'AM', 'AT', 'BY', 'BE', 'BA', 'BG', 'CH', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FO', 'FI', 'FR', 'GB', 'GE', 'GI', 'GR', 'HU', 'HR', 'IE', 'IS', 'IT', 'LT', 'LU', 'LV', 'MC', 'MK', 'MT', 'NO', 'NL', 'PO', 'PT', 'RO', 'RU', 'SE', 'SI', 'SK', 'SM', 'TR', 'UA', 'VA'];
				if (euCountryCodes.includes(countryCode)) {
					let consentBoxId = 'gdpr_consent';
					let consentBoxSelector = '#' + consentBoxId;
					let consentBox = `
								<div id="${consentBoxId}" class="container alert alert-secondary alert-dismissible fixed-bottom text-center fade" role="alert" >
									By using our site, you acknowledge that you have read and understand our policy.
									<button type="button" class="close" style="float:initial"  data-dismiss="alert" aria-label="Close">
										<span aria-hidden="true">&times;</span>
									</button>
								</div>
							`;
					jQuery("body").append(consentBox);
					// Show the alert
					jQuery(consentBoxSelector).addClass('show');
					// When it's closed, we save the consent
					jQuery(consentBoxSelector).on('closed.bs.alert', function () {
						//  This event is fired when the alert has been closed (will wait for CSS transitions to complete)
						localStorage.setItem(consentKey, true);
                                                console.log ('Consent was saved');
					})
				} else {
					localStorage.setItem(consentKey, consentValueNonEu);
				}
			}
		}
	)
}

When storing the consent, you can use the following table structure:

  • date-time
  • consent-id (id)
  • consent-url (origin of the consent)
  • consent-necessary (yes/no)
  • consent-preferences (yes/no)
  • consent-statistics (yes/no)
  • consent-marketing (yes/no)
  • consent-unknown (yes/no)
  • ip-anonymized (hashed)
  • user-agent
  • ip-country
Advertising

5 - Documentation / Reference