Mobile app version of vmapp.org
Login or Join
Martha676

: 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,

@Martha676

Posted in: #Ecommerce #GoogleAnalytics #Tracking

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?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Martha676

1 Comments

Sorted by latest first Latest Oldest Best

 

@Smith883

Yeah, it appears that you have all the required parameters. I suggest you test it with a tool like HTTPFox or Google Analytics Debugger.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme