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.

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 mapping from IAB TCF to Google Consent Mode as recommended by Google. The Google Consent Mode items will be set to granted if the purposes or special features are switched on.

itempurposesspecial features
ad_storage1any
ad_user_data1, 7any
ad_personalization3, 4any
analytics_storageanyany
functionality_storageanyany
personalization_storageanyany
security_storageanyany

Google Signals will be disabled in Google Analytics if either purpose 7, 9 or 10 are switched off.

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
purpose2advertising
purpose3ads_profile
purpose4personalised_ads
purpose5content_profile
purpose6content
purpose7ad_performance
purpose8content_performance
purpose9market_research
purpose10product_improvement
purpose11content_limited_data
special feature1precise_geo
special feature2device_scan