---
title: Filter the Google consent mode default
url: "https://www.seopress.org/support/hooks/filter-the-google-consent-mode-default/"
lang: en-US
updated: 2026-10-20
hook_name: seopress_user_consent
required_version: 7.8
---

# Filter the Google consent mode default

- **Hook name:** `seopress_user_consent`
- **Required version:** 7.8

```php
<?php
function sp_user_consent( $consent ) {
	// $consent is the gtag('consent', 'default', {...}) JavaScript snippet.
	return str_replace( "'analytics_storage': 'denied'", "'analytics_storage': 'granted'", $consent );
}
add_filter( 'seopress_user_consent', 'sp_user_consent' );
```

Source: [https://gist.github.com/wp-seopress/a296174ab35ef40492f4ac534b089691](https://gist.github.com/wp-seopress/a296174ab35ef40492f4ac534b089691)


The value is JavaScript code printed in the page. Only return trusted code.
