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