Filter Google Analytics tracking with a custom dimension

Since SEOPress 2.6

function sp_gtag_cd_hook_cf($html) {
return "'dimension6': 'custom_dimension',";
}
add_filter('seopress_gtag_cd_hook_cf', 'sp_gtag_cd_hook_cf');

function sp_gtag_cd_hook_ev($html) { 
return "gtag('event', '".__('My custom dimension','wp-seopress')."', {'custom_dimension': 'my_custom_data'});"; 
}
add_filter('seopress_gtag_cd_hook_ev', 'sp_gtag_cd_hook_ev');

Last modified: April 1, 2018