---
title: Add custom tracking code with user consent
url: "https://www.seopress.org/support/hooks/add-custom-tracking-code-with-user-consent/"
lang: en-US
updated: 2021-09-29
hook_name: seopress_custom_tracking
required_version: 3.0
---

# Add custom tracking code with user consent

- **Hook name:** `seopress_custom_tracking`
- **Required version:** 3.0

```php
function sp_custom_tracking($html) { 
	return "<script>my custom tracking code (eg: Facebook Pixel code)</script>"; 
}
add_filter('seopress_custom_tracking', 'sp_custom_tracking'); 
```

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



