Created
April 10, 2024 09:24
-
-
Save elias1435/5d7248058650360f38a703c91e9b38c2 to your computer and use it in GitHub Desktop.
Add tracking code only in woocommerce order received page
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
/** | |
* Add tracking code on Order received/thank you page. | |
* | |
* @return void | |
*/ | |
function md_thankyou_page_tracking_code() { | |
if ( ! is_wc_endpoint_url( 'order-received' ) ) { | |
return; | |
} | |
?> | |
<!-- Event snippet for Purchase (1) conversion page --> | |
<script> | |
gtag('event', 'conversion', { | |
'send_to': 'AW-000000000/000000000_000000000', | |
'value': 1.0, | |
'currency': 'GBP', | |
'transaction_id': '' | |
}); | |
</script> | |
<?php | |
} | |
add_action( 'wp_footer', 'md_thankyou_page_tracking_code' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment