1
我想添加一個谷歌的AdWords標籤,到廣告購物車按鈕來跟蹤轉換。 我需要把它放在哪裏?轉換跟蹤添加到購物車按鈕woocommerce
還是我完全在旁邊,我必須以不同的方式解決它?如果有人能幫助我,將是非常好的:)
這是代碼:
<script type="text/javascript">
/* <![CDATA[ */
goog_snippet_vars = function() {
var w = window;
w.google_conversion_id = ***************;
w.google_conversion_label = "************";
w.google_remarketing_only = false;
}
// DO NOT CHANGE THE CODE BELOW.
goog_report_conversion = function(url) {
goog_snippet_vars();
window.google_conversion_format = "3";
var opt = new Object();
opt.onload_callback = function() {
if (typeof(url) != 'undefined') {
window.location = url;
}
}
var conv_handler = window['google_trackConversion'];
if (typeof(conv_handler) == 'function') {
conv_handler(opt);
}
}
/* ]]> */
</script>
<script type="text/javascript"
src="//www.googleadservices.com/pagead/conversion_async.js">
</script>
這就是我想要把它:
/wp-content/plugins/woocommerce/templates /單品/ add-to-cart/simple.php
<?php
if (! defined('ABSPATH')) {
\t exit;
}
global $product;
if (! $product->is_purchasable()) {
\t return;
}
echo wc_get_stock_html($product);
if ($product->is_in_stock()) : ?>
\t <?php do_action('woocommerce_before_add_to_cart_form'); ?>
\t <form class="cart" method="post" enctype='multipart/form-data'>
\t \t <?php
\t \t \t /**
\t \t \t * @since 2.1.0.
\t \t \t */
\t \t \t do_action('woocommerce_before_add_to_cart_button');
\t \t \t /**
\t \t \t * @since 3.0.0.
\t \t \t */
\t \t \t do_action('woocommerce_before_add_to_cart_quantity');
\t \t \t woocommerce_quantity_input(array(
\t \t \t \t 'min_value' => apply_filters('woocommerce_quantity_input_min', $product->get_min_purchase_quantity(), $product),
\t \t \t \t 'max_value' => apply_filters('woocommerce_quantity_input_max', $product->get_max_purchase_quantity(), $product),
\t \t \t \t 'input_value' => isset($_POST['quantity']) ? wc_stock_amount($_POST['quantity']) : $product->get_min_purchase_quantity(),
\t \t \t));
\t \t \t /**
\t \t \t * @since 3.0.0.
\t \t \t */
\t \t \t do_action('woocommerce_after_add_to_cart_quantity');
\t \t ?>
\t \t <button type="submit" name="add-to-cart" value="<?php echo esc_attr($product->get_id()); ?>" class="single_add_to_cart_button button alt"><?php echo esc_html($product->single_add_to_cart_text()); ?></button>
\t \t <?php
\t \t \t /**
\t \t \t * @since 2.1.0.
\t \t \t */
\t \t \t do_action('woocommerce_after_add_to_cart_button');
\t \t ?>
\t </form>
\t <?php do_action('woocommerce_after_add_to_cart_form'); ?>
<?php endif; ?>
對不起,第一個標記是檢查頁面是否被加載,第二個標記是檢查什麼時候被點擊。 –
感謝您的幫助!!!!!!!我真的很感激它!,你可以請我的quastion與好標籤? –
只需在您的分析中創建一個新的轉換並使用我的代碼,我不知道您使用的是什麼類型的代碼。我一直在使用我的例子:) –