# cookiebot/4.7.4/src/view/frontend/scripts/common/google-consent-mode-js.php

Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA &amp; Google Consent Mode, version 4.7.4. 35 lines.

- Page: https://pluginprobe.com/plugins/cookiebot/4.7.4/code/src/view/frontend/scripts/common/google-consent-mode-js.php
- Raw: https://pluginprobe.com/plugins/cookiebot/4.7.4/raw/src/view/frontend/scripts/common/google-consent-mode-js.php
- Modified: 2025-05-29T07:41:02+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/cookiebot/4.7.4/code/src/view/frontend/scripts/common/google-consent-mode-js.php#L10-L20`.

```php
<?php
/**
 * @var string $data_layer
 * @var string $url_passthrough
 * @var bool|string $consent_attribute
 * @var string $script_type
 */

?>
<script type="<?php echo esc_attr( $script_type ); ?>"<?php echo ! $consent_attribute ? '' : ' data-cookieconsent="' . esc_attr( $consent_attribute ) . '"'; ?>>
	window.<?php echo esc_js( $data_layer ); ?> = window.<?php echo esc_js( $data_layer ); ?> || [];

	function gtag() {
		<?php echo esc_js( $data_layer ); ?>.push(arguments);
	}

	gtag("consent", "default", {
		ad_personalization: "denied",
		ad_storage: "denied",
		ad_user_data: "denied",
		analytics_storage: "denied",
		functionality_storage: "denied",
		personalization_storage: "denied",
		security_storage: "granted",
		wait_for_update: 500,
	});
	gtag("set", "ads_data_redaction", true);
	<?php
	if ( $url_passthrough ) {
		echo /** @lang JavaScript */
			'gtag("set", "url_passthrough", true);' . PHP_EOL;
	}
	?>
</script>

```
