Created
February 28, 2019 18:44
-
-
Save wp-seopress/3c981262d4c3595c4aca13da89b8e613 to your computer and use it in GitHub Desktop.
Filter Google Analytics affiliate / outbound links tracking
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_outbound_tracking_ev($html) { | |
| return "jQuery(document).ready(function() { | |
| jQuery('a').filter(function() { | |
| return this.href.match(/(?:\/".seopress_google_analytics_affiliate_tracking_option()."\/)/gi); | |
| }).click(function(e){ | |
| gtag('event', 'click', {'event_category': 'outbound/affiliate','event_label' : this.href}); | |
| }); | |
| }); | |
| "; | |
| } | |
| add_filter('seopress_gtag_outbound_tracking_ev', 'sp_gtag_outbound_tracking_ev'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment