WordPress Affiliate Manager › Forums › Affiliate Manager Plugin › Pixel Facebook – Thank you Page woocommerce
- This topic has 3 replies, 2 voices, and was last updated 5 years, 10 months ago by
metius.
-
AuthorPosts
-
May 28, 2020 at 5:52 pm #6758
metius
ParticipantHello,
i have an affiliate with id number 67 that would add pixel facebook on thank you page…
– this code is correct?
– how can add their commission for each order instead of $order->get_total() ??thank you
$aff_id = $_COOKIE[‘wpam_id’];
if(isset($aff_id) && $aff_id == ’67’) {add_action( ‘woocommerce_thankyou’, ‘my_custom_tracking’ );
function my_custom_tracking( $order_id ) {
// Lets grab the order
$order = wc_get_order( $order_id );?>
<!– Facebook Pixel Code –>
<script>
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version=’2.0′;
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,’script’,
‘https://connect.facebook.net/en_US/fbevents.js’);
fbq(‘init’, ‘myfacebookpixel’);
fbq(‘trackSingle’, ‘myfacebookpixel’, ‘Purchase’, {value: <?php echo $order->get_total(); ?>,
currency: ‘EUR’,
});
</script><!– End Facebook Pixel Code –>
<?php
// This is the order total
$order->get_total();}
}
June 1, 2020 at 11:26 am #6767metius
Participanti changed it so:
if (isset($_COOKIE[‘wpam_id’])) {
$aff_id = $_COOKIE[‘wpam_id’];
if($aff_id == ’67’)
add_action( ‘woocommerce_thankyou’, ‘my_custom_tracking’ );
function my_custom_tracking( $order_id ) {
// Lets grab the order
$order = wc_get_order( $order_id );/**
* Put your tracking code here
*/?>
<!– Facebook Pixel Code –>
<script>
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version=’2.0′;
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,’script’,
‘https://connect.facebook.net/en_US/fbevents.js’);
fbq(‘init’, ‘myfacebookpixel’);
fbq(‘trackSingle’, ‘myfacebookpixel’, ‘Purchase’, {value: <?php echo ($order->get_subtotal() – $order->get_total_discount()) * 0.15; ?>,
currency: ‘EUR’,
});
</script><!– End Facebook Pixel Code –>
<?php
// This is the order total
$order->get_total();
$order->get_subtotal();
$order->get_total_discount();}
}June 2, 2020 at 11:49 pm #6771mbrsolution
ModeratorHi, I am curious to know if your solution works for you?
Thank you
June 11, 2020 at 5:43 pm #6783metius
ParticipantHi, it works but if someone for any reasons update thank you page or pay with paypal and close page before redirect on thank you page it distorts data sent to the pixel.
So I’d like trying something like adding action for new order that should check if meta key (“_wpam_id”) for new order exist.
but i don’t know how to get it…
-
AuthorPosts
- You must be logged in to reply to this topic.