Created
May 20, 2016 18:19
-
-
Save tamarazuk/96a3b15c9db0ea14963002de86683d6f to your computer and use it in GitHub Desktop.
WooCommerce Google Analytics Pro - Ensure off-site gateways aren't tracked as referrers
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
<?php // only copy this line if needed | |
/** | |
* Add the utm_nooverride parameter to any return urls. This makes sure Google Adwords doesn't mistake the offsite gateway as the referrer. | |
* | |
* @link https://github.com/woothemes/woocommerce-google-analytics-integration/blob/c805bb4c24de235227c2b4b21b179d73bd8a7861/includes/class-wc-google-analytics.php#L506-L522 | |
* | |
* @param string $return_url WooCommerce Return URL | |
* @return string URL | |
*/ | |
function sv_wc_google_analytics_pro_utm_nooverride( $return_url ) { | |
// remove the utm_nooverride param in case it exists | |
$return_url = remove_query_arg( 'utm_nooverride', $return_url ); | |
// add utm_nooverride param to return URL | |
$return_url = add_query_arg( 'utm_nooverride', '1', $return_url ); | |
return $return_url; | |
} | |
add_filter( 'woocommerce_get_return_url', 'sv_wc_google_analytics_pro_utm_nooverride' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment