pinterest转换跟踪标签,用于WooCommerce订单



我需要将pinterest转换标签安装到WooCommerce订单中动态跟踪'value'和'order_quantity'。Pinterest标签具有JavaScript的2个部分。第1部分是网站标题中的基本代码。第2部分是结帐标题中的事件代码。

我认为第2部分是必须在下面修改的(value and 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

我在这一点上很迫切,所以任何帮助都将不胜感激...

奖励!

将其放入您的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-thanks-page/

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

最新更新