Тег отслеживания конверсий Pinterest для заказов WooCommerce

Мне нужно установить тег конверсии Pinterest, чтобы динамически отслеживать «значение» и «количество_заказа» из заказов WooCommerce. Тег Pinterest состоит из двух частей Javascript. Часть 1 — это базовый код, который находится в шапке сайта. Часть 2 — это код события, который указывается в заголовке Checkout.

Я думаю, что часть 2 — это то, что должно быть изменено ниже (значение и количество_заказа необходимо изменить, чтобы получить заказы из 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

На данный момент я в отчаянии, поэтому любая помощь будет принята с благодарностью... и вознаграждена!


person willywhy    schedule 16.04.2017    source источник


Ответы (1)


Поместите это в свой functions.php и измените Your_Tag_ID, чтобы он соответствовал идентификатору тега, который у вас есть в Pinterest.

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/

person logrexton    schedule 13.02.2018
comment
Вы забыли письмо с хешированными данными. - person Kevin Nguyen; 02.05.2018