Created
October 27, 2021 07:33
-
-
Save xlplugins/cb3fecaf67bfd11301e2fe5faac96191 to your computer and use it in GitHub Desktop.
eddie tiktok tracking script
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
/** | |
* Rendering Custom tracking script for thank you and upsell pages. | |
* | |
* @param $general_data | |
*/ | |
function render_custom_script_tracking( $general_data ) { | |
?> | |
<script> | |
//part1 | |
!function (w, d, t) { | |
w.TiktokAnalyticsObject=t;var ttq=w[t]=w[t]||[];ttq.methods=["page","track","identify","instances","debug","on","off","once","ready","alias","group","enableCookie","disableCookie"],ttq.setAndDefer=function(t,e){t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}};for(var i=0;i<ttq.methods.length;i++)ttq.setAndDefer(ttq,ttq.methods[i]);ttq.instance=function(t){for(var e=ttq._i[t]||[],n=0;n<ttq.methods.length;n++)ttq.setAndDefer(e,ttq.methods[n]);return e},ttq.load=function(e,n){var i="https://analytics.tiktok.com/i18n/pixel/events.js";ttq._i=ttq._i||{},ttq._i[e]=[],ttq._i[e]._u=i,ttq._t=ttq._t||{},ttq._t[e]=+new Date,ttq._o=ttq._o||{},ttq._o[e]=n||{};var o=document.createElement("script");o.type="text/javascript",o.async=!0,o.src=i+"?sdkid="+e+"&lib="+t;var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(o,a)}; | |
//part2 | |
ttq.load('###########'); | |
ttq.page(); | |
}(window, document, 'ttq'); | |
</script> | |
<script type="text/javascript"> | |
if (undefined !== wfocu_tracking_data && '' !== wfocu_tracking_data) { | |
let order_id = ''; | |
if ("undefined" !== typeof wfocu_tracking_data.ga_transaction_id && '' !== wfocu_tracking_data.ga_transaction_id) { | |
order_id = wfocu_tracking_data.ga_transaction_id; | |
}else if ("undefined" !== typeof wfocu_tracking_data.transaction_id){ | |
order_id = wfocu_tracking_data.transaction_id; | |
} | |
ttq.instance('pixel_id_1').track('CompletePayment') | |
//USE THESE DYNAMIC VARIABLES IN YOUR SCRIPT | |
//wfocu_tracking_data.total //For order total | |
//wfocu_tracking_data.currency //For order currency | |
//wfocu_tracking_data.ga_transaction_id //For order ID | |
//wfocu_tracking_data.email //For order Email | |
//wfocu_tracking_data.first_name //For order user First name | |
//wfocu_tracking_data.last_name //For order user Last name | |
//wfocu_tracking_data.revenue //For order total or revenue | |
//wfocu_tracking_data.shipping //For order Shipping cost | |
//wfocu_tracking_data.tax //For order Tax | |
} | |
</script> | |
<?php | |
} | |
add_action( 'wfocu_custom_purchase_tracking', 'render_custom_script_tracking' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment