Skip to content

Instantly share code, notes, and snippets.

@jdeeburke
Created September 18, 2018 15:33
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 jdeeburke/9e1db6567cac1ea9e907ae2218f24359 to your computer and use it in GitHub Desktop.
Save jdeeburke/9e1db6567cac1ea9e907ae2218f24359 to your computer and use it in GitHub Desktop.
Override Google Analytics Pro event name for renewal purchases
<?php
function sv_wc_google_analytics_pro_set_completed_renewal_purchase_event( $parameters ) {
if ( 'completed purchase' === $parameters['ea'] ) {
$order_id = (int) $parameters['el'];
if ( WC_Subscriptions_Renewal_Order::is_renewal( $order_id ) ) {
$parameters['ea'] = 'completed renewal purchase';
}
}
return $parameters;
}
add_filter( 'wc_google_analytics_pro_api_event_parameters', 'sv_wc_google_analytics_pro_set_completed_renewal_purchase_event', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment