我想发送特定于交易的转化价值,即:$totalValue
与谷歌广告一起谷歌分析。
当前设置仅将 $totaValue 信息发送到谷歌广告。
我怎样才能将该信息也发送到谷歌分析?
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = id;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "sdvpCJaTwloQgs8YxgM";
var google_conversion_currency = "USD";
if (<? echo $totalValue ?>) {
var google_conversion_value = <? echo $totalValue ?>;
}
var google_remarketing_only = false;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/id/?value=<? echo $totalValue ?>&currency_code=USD&label=sdvpCJaTwloQgs8YxgM&guid=ON&script=0"/>
</div>
</noscript>
感谢 Michele,我发现了使用 google 分析的事务方法,但我的 PHP 值没有被解析,并阻止了其余代码的加载。
ga('create', 'UA-xxxxxxxx-x', 'auto');
ga('send', 'pageview');
ga('require', 'ecommerce');
ga('ecommerce:addTransaction', {
'id': '<?php echo $order; ?>',
'revenue': '<?php echo $transactionValue; ?>',
});
ga('ecommerce:send');