Created
February 28, 2019 18:54
-
-
Save wp-seopress/9f3eb37c99e507554666962588d59840 to your computer and use it in GitHub Desktop.
Filter Google Analytics tracking with a custom dimension
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_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'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment