简体   繁体   English

将Google Analytics(分析)电子商务跟踪添加到woocommerce

[英]Adding google analytics ecommerce tracking to woocommerce

I need to add the google analytics ecommerce tracking to a wordpress site with woocommerce. 我需要使用woocommerce将Google Analytics(分析)电子商务跟踪添加到wordpress网站。

I understand I need to add the code for tracking and on this page https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce it says I need to add some codes to a thank you page. 我了解我需要添加用于跟踪的代码,并且在此页面https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce上说,我需要在感谢页面上添加一些代码。

I've tried adding these codes via a add_action( 'woocommerce_thankyou', 'my_custom_tracking' ); 我试过通过add_action( 'woocommerce_thankyou', 'my_custom_tracking' );添加这些代码add_action( 'woocommerce_thankyou', 'my_custom_tracking' ); but in most cases I get some php error or it doesn't work. 但在大多数情况下,我会遇到一些PHP错误,或者它无法正常工作。

Also, I've tried google ecommerce integration plugin but it didn't work. 另外,我尝试了Google电子商务集成插件,但没有用。

What part of the GA ecommerce tracking code do I need to add and where to be able to track conversions on google analytics ? 我需要添加GA电子商务跟踪代码的哪一部分,以及在哪里能够跟踪Google Analytics(分析)的转化?

First You need to add analytics tracking code in the footer. 首先,您需要在页脚中添加分析跟踪代码。 You can do that like this: 您可以这样做:

<?php
function your_function() {
   echo '<p>This is inserted at the bottom</p>';
}
add_action( 'wp_footer', 'your_function' );
?>

Then you need to add conversion tracking code, You can do that by editing your theme's thankyou.php page 然后,您需要添加转化跟踪代码,可以通过编辑主题的thankyou.php页面来实现

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM