cookiebot-js.php
3 years ago
google-consent-mode-js.php
3 years ago
google-tag-manager-js.php
3 years ago
google-consent-mode-js.php
30 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @var string $data_layer |
| 4 | * @var string $url_passthrough |
| 5 | * @var bool|string $consent_attribute |
| 6 | */ |
| 7 | |
| 8 | ?> |
| 9 | <script<?php echo ! $consent_attribute ? '' : ' data-cookieconsent="' . esc_attr( $consent_attribute ) . '"'; ?>> |
| 10 | window.<?php echo esc_js( $data_layer ); ?> = window.<?php echo esc_js( $data_layer ); ?> || []; |
| 11 | function gtag() { |
| 12 | <?php echo esc_js( $data_layer ); ?>.push(arguments); |
| 13 | } |
| 14 | gtag("consent", "default", { |
| 15 | ad_storage: "denied", |
| 16 | analytics_storage: "denied", |
| 17 | functionality_storage: "denied", |
| 18 | personalization_storage: "denied", |
| 19 | security_storage: "granted", |
| 20 | wait_for_update: 500, |
| 21 | }); |
| 22 | gtag("set", "ads_data_redaction", true); |
| 23 | <?php |
| 24 | if ( $url_passthrough ) { |
| 25 | echo /** @lang JavaScript */ |
| 26 | 'gtag("set", "url_passthrough", true);' . PHP_EOL; |
| 27 | } |
| 28 | ?> |
| 29 | </script> |
| 30 |