Analytics · Advanced Topics · Google Consent Mode v2

Google Consent Mode allows web and app developers to adjust tag and app SDK behavior based on user consent choices. Onesecondbefore fully integrates Google Consent Mode v2 in their CMP offering.

Supported Google Consent Mode types

typedescription
ad_storageEnables storage, such as cookies (web) or device identifiers (apps), related to advertising.
ad_user_dataSets consent for sending user data to Google for online advertising purposes.
ad_personalizationSets consent for personalized advertising.
analytics_storageEnables storage, such as cookies (web) or device identifiers (apps), related to analytics, for example, visit duration.
functionality_storageEnables storage that supports the functionality of the website or app, for example, language settings
personalization_storageEnables storage related to personalization, for example, video recommendations
security_storageEnables storage related to security such as authentication functionality, fraud prevention, and other user protection

Automatic integration with our IAB TCF Consent Wall

In case you use our IAB TCF Consent Wall, we provide an automatic connection to Google Consent Mode. In case a user denies all consent, we set all Google Consent Mode types to 'denied'. In case a user selects to accept all consents, we set all Google Consent Mode types to 'granted'. In case a user wants to manually select (special) purposes and (special) features, we set the Google Consent Mode type to 'granted' only if they accepted the purposes and special features as set below.

typepurposesspecial features
ad_storage1, 2, 7 and 9any
ad_user_data91 and 2
ad_personalization2, 3, 4, 7 and 9any
analytics_storage1, 8, 9 and 10any
functionality_storageanyany
personalization_storage1, 5, 6, 9 and 11any
security_storageanyany

Please be advised that Onesecondbefore offers this as a recommendation. Neither the IAB or Google supplied a mapping between the two consent frameworks. If you would like to change the default behaviour, please read on in the next section.

Manual integration of your CMP

In case you use the consent banner of our CMP or a third party CMP, you can use the code examples below to enable Google Consent Mode on your website.

You enable Google Consent Mode in Onesecondbefore with adding the googleConsentMode config parameter to the page tag. The parameter should contain a call to an existing function or an anonymous function that return a JSON object with the Google Consent Mode types set to either 'denied' or 'granted'. The following example contains a configuration with an existing function.

Example

osb('config', {
    accountId: 'act123',
    cookieDomain: 'mydomain.com',
    cookieNamePrefix: '_osb_',
    cookiePath: '/',
    cookieSettings: 1,
    siteId: 'mygreatsite',
    forceGET: false,
    ipSettings: 0,
    userCookieTimeout: 31536000,
    googleConsentMode: (purposes) => {
        return {
            ad_storage: purposes.includes('all') || purposes.includes('advertising') ? 'granted' : 'denied’,
            ...
        }
    }
});

And the example below contains the configuration with an existing function.

function getGoogleConsentMode(purposes) {
    return {
        ad_storage: purposes.includes('all') || purposes.includes('advertising') ? 'granted' : 'denied’,
        ...
    }
}
osb('config', {
    accountId: 'act123',
    cookieDomain: 'mydomain.com',
    cookieNamePrefix: '_osb_',
    cookiePath: '/',
    cookieSettings: 1,
    siteId: 'mygreatsite',
    forceGET: false,
    ipSettings: 0,
    userCookieTimeout: 31536000,
    googleConsentMode: getGoogleConsentMode
});

Default purposes

Below is a list of default purposes that can be expected when using our Consent Bar. Source

purposedescription
necessaryStrictly necessary cookies — These cookies are essential for you to browse the website and use its features, such as accessing secure areas of the site. Cookies that allow web shops to hold your items in your cart while you are shopping online are an example of strictly necessary cookies. These cookies will generally be first-party session cookies. While it is not required to obtain consent for these cookies, what they do and why they are necessary should be explained to the user.
analyticsThese cookies collect information about how you use a website, like which pages you visited and which links you clicked on. Data can be matched and combined with other data sources. Different devices can be linked.
personalizationPersonalization cookies - Creation and use of profiles to deliver a personalized experience on your website.
advertisementThese cookies track your online activity to help advertisers deliver more relevant advertising or to limit how many times you see an ad on a publisher website. These cookies can share that information with other organizations or advertisers. These are persistent cookies and almost always of third-party provenance.
socialThese cookies track your online activity to help social networks to deliver more relevant content on a social platform. These cookies can share that information with other organizations or advertisers. These are persistent cookies and almost always of third-party provenance.

IAB TCF purposes

In case you would like to rewrite the default behaviour of the Consent Wall, all purpose and feature names are sent as a string array argument. The table below contains the purpose or feature and the readable name we chose to identify a particular purpose.

purpose or featurenumbername
purpose1storage
purpose2ad_select_limited
purpose3ad_profiles
purpose4ad_personalization
purpose5content_profiles
purpose6content_personalization
purpose7ad_performance
purpose8content_performance
purpose9analytics
purpose10service_performance
purpose11content_select_limited
special feature1precise_geo
special feature2device_scan