Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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']);

        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 ?>;


    $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)) {


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?

share|improve this question

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.