Filter categories tracking custom dimension with Google Analytics

Since SEOPress 2.6

function sp_gtag_cd_categories_cf($html) {
return "'dimension2': 'cd_categories',";
}
add_filter('seopress_gtag_cd_categories_cf', 'sp_gtag_cd_categories_cf');

function sp_gtag_cd_categories_ev($html) { 
return "gtag('event', '".__('Categories','wp-seopress')."', {'cd_categories': '".$get_first_category."'});"; 
} 
add_filter('seopress_gtag_cd_categories_ev', 'sp_gtag_cd_categories_ev');

Last modified: April 1, 2018