0

我需要安装Pinterest转换标记才能从WooCommerce订单动态追踪'value'和'order_quantity'。 Pinterest标签包含2个Javascript部分。第1部分是网站标题中的基本代码。第2部分是Checkout标题中的事件代码。WooCommerce订单的Pinterest转换追踪标记

我认为第2部分就是必须低于(价值和order_quantity需要改变从WooCommerce订单拉)进行修改:

<script> 
pintrk('track', ' checkout ', { 
    value: {{Enhanced Transaction Revenue}}, 
    order_quantity: {{item.quantity}} 
    }); 
</script> 
<noscript> 
<img height="1" width="1" style="display:none;" alt="" src=" https://ct.pinterest.com/v3/?tid= 123456789 &event= checkout &noscript=1" /> </noscript> 

Pinterest的转换标签指南这里:https://help.pinterest.com/sites/help/files/pinterest_tag_instructions.pdf

我绝望在这一点,所以任何帮助将不胜感激...并奖励!

回答

0

把它放在你的functions.php中,并且改变Your_Tag_ID以匹配你在Pinterest上的标记ID。

add_action('woocommerce_thankyou', 'pinterest_tracking'); 

function pinterest_tracking($order_id) { 

// Lets grab the order 
$order = wc_get_order($order_id); 

/** 
* Put your tracking code here 
* You can get the order total etc e.g. $order->get_total(); 
*/ 

// This is the order total 
$order_total = $order->get_total(); 
$order_quantity = $order->get_item_count(); 

?> 

<script> 
    pintrk('track', 'checkout', { 
     { 
      value: '<?php echo $order_total ?>', 
      order_quantity: '<?php echo $order_quantity ?>', 
      currency: 'USD' 
     } 
    ]); 
</script> 
<noscript> 
<img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=Your_Tag_ID&event=checkout&ed[value]=<?php echo $order_total ?>&ed[order_quantity]=<?php echo $order_quantity ?>&noscript=1"/> 
</noscript> 
<?php 

} 

这里有两个环节,帮助我:

https://docs.woocommerce.com/document/custom-tracking-code-for-the-thanks-page/

https://developers.pinterest.com/docs/ad-tools/conversion-tag/