PageSourceSearch

https://www.dcbib.dk/modules/contrib/cookieinformation/js/consent_mode_v2.js?tm868m

js dcbib.dk collected 2026-10-02 18:44:13 UTC 1,099 bytes, 40 lines download raw bytes

1/* global gtag, CookieInformation */
2/* exported gtag */
3
4/**
5 * @file
6 * Adds event listener to follow changes in Google Consent mode.
7 *
8 * @see https://support.cookieinformation.com/en/articles/8886647-consent-mode-v2-implementation
9 *
10 */
11
12/**
13 * Handles the "CookieInformationConsentGiven" event to update Google Consent Mode settings
14 * based on the user's consent preferences.
15 *
16 * Checks if the user has given consent for analytics and marketing cookies and updates
17 * the Google Consent Mode accordingly to enable or restrict certain features.
18 *
19 * @function handleConsentGivenEvent
20 * @global
21 */
22function handleConsentGivenEvent() {
23  if (CookieInformation.getConsentGivenFor('cookie_cat_statistic')) {
24    gtag('consent', 'update', { analytics_storage: 'granted' });
25  }
26
27  if (CookieInformation.getConsentGivenFor('cookie_cat_marketing')) {
28    gtag('consent', 'update', {
29      ad_storage: 'granted',
30      ad_user_data: 'granted',
31      ad_personalization: 'granted',
32    });
33  }
34}
35
36window.addEventListener(
37  'CookieInformationConsentGiven',
38  handleConsentGivenEvent,
39  false,
40);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.