Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Last active October 7, 2021 11:48
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 Pebblo/f14692803ebef6ab2e9f1750e1ea7c50 to your computer and use it in GitHub Desktop.
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.
<?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