Skip to content

Instantly share code, notes, and snippets.

@harishankerr
Created December 1, 2016 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harishankerr/0fa72ffe168174d92825180c271e3b88 to your computer and use it in GitHub Desktop.
Save harishankerr/0fa72ffe168174d92825180c271e3b88 to your computer and use it in GitHub Desktop.
<?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