I want to send a transaction-specific conversion value i.e: $totalValue
to google analytics alongside Google ad.
The current setup only sends the $totaValue info to google ads.
How can I send that info to google analytics as well?
<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>
Thanks to Michele I discovered the transaction method with google analytics but my PHP values aren't being parsed and prevent the rest of the code from loading.
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');
You can use transaction and item hits: https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce.
Or an event with value.