Created
February 28, 2019 18:45
-
-
Save wp-seopress/395c5ccf795797d4659fc79022bfae28 to your computer and use it in GitHub Desktop.
Filter Google Analytics Cross-domain tracking feature
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_download_tracking_ev($html) { | |
| return "jQuery(document).ready(function() { | |
| jQuery('a').filter(function() { | |
| return this.href.match(/.*\.(pdf|docx|xlsx)(\?.*)?$/); }).click(function(e) { | |
| gtag('event', 'click', {'event_category': 'downloads','event_label' : this.href}); | |
| }); | |
| }); | |
| "; | |
| } | |
| add_filter('seopress_gtag_download_tracking_ev', 'sp_gtag_download_tracking_ev'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment