: Implementing Google ecommerce tracking code I am trying to set up e-commerce tracking on my custom e-commerce site. On the thank you for ordering page I have added this code at the bottom,
I am trying to set up e-commerce tracking on my custom e-commerce site.
On the thank you for ordering page I have added this code at the bottom, it also has the normal ga.js tracking code in the header, as it does on every page of the site.
<script type="text/javascript">
// Google Analytics
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-31467450-1']);
_gaq.push(['_trackPageview']);
transactionId = <?php echo $order_id ?>;
affiliation = '';
total = <?php echo $grand_total ?>;
tax = <?php echo $vat_total ?>;
shipping = <?php echo $shipping_total ?>;
country = <?php echo $address ?>;
_gaq.push(['_addTrans',
transactionId,
affiliation,
total,
tax,
shipping,
city,
state,
country
]);
<?php
$item_qry = mysql_query("SELECT `products_price`,`products_quantity`,`products_name`,`products_model` FROM `orders_products` WHERE `orders_id`=$order_id");
while($item_row = mysql_fetch_assoc($item_qry)) {
echo"_gaq.push(['_addItem','$order_id','$item_row['products_model']','$item_row['products_name']','','$item_row['products_price']',$item_row['products_quantity'])";
}
?>
_gaq.push(['_trackTrans']);
</script>
Is this all that is required to track ecommerce?
I added the loop so it runs through every item added, do I do this correctly?
More posts by @Martha676
1 Comments
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.