Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JeroenSormani/af26582d26aef2184a3bb5f2990642f6 to your computer and use it in GitHub Desktop.
Save JeroenSormani/af26582d26aef2184a3bb5f2990642f6 to your computer and use it in GitHub Desktop.
EDD Enhanced Ecommerce Tracking 1.2+ - (Re)move tracking script to the head
<?php
// Copy from here
if ( function_exists( 'EDD_Enhanced_Ecommerce_Tracking' ) && edd_get_option( 'eddeet_implementation_method' ) == 'measurement-protocol' ) {
remove_action( 'wp_footer', array( EDD_Enhanced_Ecommerce_Tracking()->implementation, 'output_script' ) );
// Add to header -- Remove/comment the below if you want to completely remove the tracking script.
add_action( 'wp_head', array( EDD_Enhanced_Ecommerce_Tracking()->implementation, 'output_script' ) );
}
@cameronjonesweb
Copy link

This code doesn't work, it won't be removed if it uses the measurement protocol as that's hooked into wp_head, gtag and analytics.js use wp_footer.

Surely this would be better as a filter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment