Created
February 28, 2019 18:28
-
-
Save wp-seopress/69a8d7a08d9457e1445dbc1c3d40c3ca to your computer and use it in GitHub Desktop.
Filter categories tracking custom dimension with Google Analytics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment