Skip to content

Instantly share code, notes, and snippets.

@xlplugins
Last active October 29, 2024 13:02
Show Gist options
  • Select an option

  • Save xlplugins/250fa5c05712b1508338f346c53c61ef to your computer and use it in GitHub Desktop.

Select an option

Save xlplugins/250fa5c05712b1508338f346c53c61ef to your computer and use it in GitHub Desktop.
tapfiliate tracking script #Upstroke #tracking
/**
* Rendering Custom tapfiliate tracking script for thank you and upsell pages.
*
* @param $general_data
*/
function wfocu_render_tapfiliate_script_tracking( $general_data ) {
if ( ! is_array( $general_data ) || 0 === count( $general_data ) ) {
return;
}
$order_id = isset( $general_data['order_id'] ) ? $general_data['order_id'] : 0;
if ( 0 === $order_id && isset( $_GET['order_id'] ) ) {
$order_id = $_GET['order_id'];
}
if ( empty( $order_id ) ) {
return;
}
$order = wc_get_order( $order_id );
if ( empty( $order ) || ! $order instanceof WC_Order ) {
return;
}
$user_id = $order->get_user_id();
?>
<script src="https://script.tapfiliate.com/tapfiliate.js" type="text/javascript" async></script>
<script type="text/javascript">
if (undefined !== wfocu_tracking_data && '' !== wfocu_tracking_data) {
(function (t, a, p) {
t.TapfiliateObject = a;
t[a] = t[a] || function () {
(t[a].q = t[a].q || []).push(arguments)
}
})(window, 'tap');
tap('create', 'YOUR ACCOUNT ID', {integration: "javascript"});
tap('conversion', wfocu_tracking_data.transaction_id, wfocu_tracking_data.total, {customer_id: <?php echo $user_id; ?>}
);
}
</script>
<?php
}
add_action( 'wfocu_custom_purchase_tracking', 'wfocu_render_tapfiliate_script_tracking' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment