Last active
October 7, 2021 11:48
-
-
Save Pebblo/f14692803ebef6ab2e9f1750e1ea7c50 to your computer and use it in GitHub Desktop.
Example of a custom function to add tacking to the thank you 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
<?php | |
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file | |
add_action( | |
'AHEE__thank_you_page_overview_template__top', | |
'my_custom_tracking_code_function' | |
); | |
function my_custom_tracking_code_function($transaction) { | |
if ( $transaction instanceof EE_Transaction ) { | |
$tracking_code = | |
"<!– Event snippet for Purchase conversion page –> | |
<script> | |
gtag('event', 'conversion', { | |
'send_to': 'XX-XXXXXXXX/XXXXXXXX-XXXXXXXXX', | |
'value': {$transaction->total()}, | |
'currency': 'AUD', | |
'transaction_id': {$transaction->ID()} | |
}); | |
</script> | |
"; | |
echo $tracking_code; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment