Created
December 1, 2016 18:09
-
-
Save harishankerr/0fa72ffe168174d92825180c271e3b88 to your computer and use it in GitHub Desktop.
This file contains 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
<?php // only copy this line if needed | |
/** | |
* Remove the tracking code added by WooCommerce Google Analytics Pro | |
* - this is usefull if your theme or another plugin is adding the tracking code | |
* - and you wish to use that instead | |
*/ | |
function sv_wc_google_analytics_pro_remove_tracking_code() { | |
// check if Google Analytics Pro is active | |
if ( ! function_exists( 'wc_google_analytics_pro' ) ) { | |
return; | |
} | |
remove_action( 'wp_head', array( wc_google_analytics_pro()->get_integration(), 'ga_tracking_code' ), 9 ); | |
remove_action( 'login_head', array( wc_google_analytics_pro()->get_integration(), 'ga_tracking_code' ), 9 ); | |
// remove pageviews | |
// the following line so that your Google Analytics plugin tracks pageviews | |
remove_action( 'wp_head', array( wc_google_analytics_pro()->get_integration(), 'pageview' ) ); | |
} | |
add_action( 'init', 'sv_wc_google_analytics_pro_remove_tracking_code' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment