---
title: Filter logged in users tracking custom dimension with Google Analytics
url: "https://www.seopress.org/support/hooks/filter-logged-in-users-tracking-custom-dimension-with-google-analytics/"
lang: en-US
updated: 2021-09-29
hook_name: seopress_gtag_cd_logged_in_cf / seopress_gtag_cd_logged_in_ev
required_version: 2.6
---

# Filter logged in users tracking custom dimension with Google Analytics

- **Hook name:** `seopress_gtag_cd_logged_in_cf / seopress_gtag_cd_logged_in_ev`
- **Required version:** 2.6

```php
function sp_gtag_cd_logged_in_cf($html) {
	return "'dimension5': 'cd_logged_in',";
}
add_filter('seopress_gtag_cd_logged_in_cf', 'sp_gtag_cd_logged_in_cf'); 

function sp_gtag_cd_logged_in_ev($html) {
	return "gtag('event', '".__('Connected users','wp-seopress')."', {'cd_logged_in': '".wp_get_current_user()->ID."'});";
}
add_filter('seopress_gtag_cd_logged_in_ev', 'sp_gtag_cd_logged_in_ev'); 
```

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



