Google Analytics and Ecommerce code

I’m having a little trouble with the code I’ve input for my google analytics to track our sales from our website. I created a code based on google’s instructions and it reports whenever someone buys something from the store, unfortunately it reports that those people are buying one of EVERYTHING from the store, as you can see in this screenshot:

I don’t know what I did to make it do this and how to set it up so it only reports exactly what the customer bought. This is the code I put into my godaddy invoice section, as per google’s instructions. Anyone see something I’m doing wrong?

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-29095748-1']);
  _gaq.push(['_trackPageview']);
  _gaq.push(['_addTrans',
    '1234',           // order ID - required
    'KoolCollar',  // affiliation or store name
    '16.99',          // total - required
    '1.29',           // tax
    '5',              // shipping
    'Vancouver',       // city
    'Washington',     // state or province
    'USA'             // country
  ]);

   // add item might be called for every item in the shopping cart
   // where your ecommerce engine loops through each item in the cart and
   // prints out _addItem for each
  _gaq.push(['_addItem',
    '1234',           // order ID - required
    'KC1203',           // SKU/code - required
    'Large Black KoolCollar w/ KoolTube',        // product name
    'Large KoolCollars',   // category or variation
    '17.99',          // unit price - required
    '1'               // quantity - required
  ]);

  _gaq.push(['_addItem',
    '1234',           // order ID - required
    'KC1103',           // SKU/code - required
    'Large Blue KoolCollar w/ KoolTube',        // product name
    'Large KoolCollars',   // category or variation
    '17.99',          // unit price - required
    '1'               // quantity - required
  ]);

  _gaq.push(['_addItem',
    '1234',           // order ID - required
    'KC1703',           // SKU/code - required
    'Large Red KoolCollar w/ KoolTube',        // product name
    'Large KoolCollars',   // category or variation
    '17.99',          // unit price - required
    '1'               // quantity - required
  ]);

  _gaq.push(['_addItem',
    '1234',           // order ID - required
    'KT103',           // SKU/code - required
    'Large KoolTube Refills',        // product name
    'Large KoolTube',   // category or variation
    '7.99',          // unit price - required
    '1'               // quantity - required
  ]);

  _gaq.push(['_addItem',
    '1234',           // order ID - required
    'KC1202',           // SKU/code - required
    'Medium Black KoolCollar w/ KoolTube',        // product name
    'Medium KoolCollar',   // category or variation
    '16.99',          // unit price - required
    '1'               // quantity - required
  ]);

  _gaq.push(['_addItem',
    '1234',           // order ID - required
    'KC1102',           // SKU/code - required
    'Medium Blue KoolCollar w/ KoolTube',        // product name
    'Medium KoolCollar',   // category or variation
    '16.99',          // unit price - required
    '1'               // quantity - required
  ]);

  _gaq.push(['_addItem',
    '1234',           // order ID - required
    'KC1702',           // SKU/code - required
    'Medium Red KoolCollar w/ KoolTube',        // product name
    'Medium KoolCollar',   // category or variation
    '16.99',          // unit price - required
    '1'               // quantity - required
  ]);

  _gaq.push(['_addItem',
    '1234',           // order ID - required
    'KT102',           // SKU/code - required
    'Medium KoolTube Refill',        // product name
    'Medium KoolTube',   // category or variation
    '6.99',          // unit price - required
    '1'               // quantity - required
  ]);

  _gaq.push(['_addItem',
    '1234',           // order ID - required
    'KC1201',           // SKU/code - required
    'Small Black KoolCollar w/ KoolTube',        // product name
    'Small KoolCollar',   // category or variation
    '15.99',          // unit price - required
    '1'               // quantity - required
  ]);

  _gaq.push(['_addItem',
    '1234',           // order ID - required
    'KC1101',           // SKU/code - required
    'Small Blue KoolCollar w/ KoolTube',        // product name
    'Small KoolCollar',   // category or variation
    '15.99',          // unit price - required
    '1'               // quantity - required
  ]);

  _gaq.push(['_addItem',
    '1234',           // order ID - required
    'KC1701',           // SKU/code - required
    'Small Red KoolCollar w/ KoolTube',        // product name
    'Small KoolCollar',   // category or variation
    '15.99',          // unit price - required
    '1'               // quantity - required
  ]);

  _gaq.push(['_addItem',
    '1234',           // order ID - required
    'KT101',           // SKU/code - required
    'Small KoolTube Refill',        // product name
    'Small KoolTube',   // category or variation
    '5.99',          // unit price - required
    '1'               // quantity - required
  ]);

  _gaq.push(['_trackTrans']); //submits transaction to the Analytics servers

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>

Your code is listing out every product as a part of the transaction thus Google is showing exactly what you told them to record.

You should be dynamically building this information starting with the order summary.


'1234',           // order ID - required
    '[B]KoolCollar[/B]',  // affiliation or store name
    '[B]16.99[/B]',          // total - required
    '[B]1.29[/B]',           // tax
    '[B]5[/B]',              // shipping
    '[B]Vancouver[/B]',       // city
    '[B]Washington[/B]',     // state or province
    '[B]USA[/B]'             // country
  ]);

And then looping through the products purchased using the format


_gaq.push(['_addItem',
    '[B]1234[/B]',           // order ID - required
    '[B]KC1203[/B]',           // SKU/code - required
    '[B]Large Black KoolCollar w/ KoolTube[/B]',        // product name
    '[B]Large KoolCollars[/B]',   // category or variation
    '[B]17.99[/B]',          // unit price - required
    '[B]1[/B]'               // quantity - required
  ]);

How you handle the dynamic insertion will depend on your ecommerce software.

What do you mean by “dynamically building” the information? With PHP?

You’re telling Google what was in the order. Since all orders are not the same this needs to be done dynamically putting the right totals, shipping costs, and products in. Right now your code is static and says to google “all these products are in this order” no matter what is actually in the order.

You’ll need to use whatever language your cart supports that you like best.

Ok that makes sense. How do I find out what language my cart supports? I’m using Godaddy shopping cart and I’m having trouble finding the right dynamic code to put in to make it access the information.

I’d start with their support team as this is presumably a very common question. If not them, you can search on their cart and the issue as again, it’s something most stores do.