[javascript] Is it possible to execute multiple _addItem calls asynchronously using Google Analytics?

Would the following code work?

_gaq.push(['_addTrans',     '7171717117', // order ID - required     '',           // affiliation or store name     '2222',       // total - required     '',           // tax     '',           // shipping     '',           // city     '',           // state or province     ''            // country ]); _gaq.push(['_trackTrans']);  _gaq.push(['_addItem',     '7171717117',   // order ID - required     '22j33j2kjk',   // SKU/code - required     'Widget 1.0',   // product name     '',             // category or variation     '2222',         // unit price - required     '1'             // quantity - required ]); _gaq.push(['_trackTrans']); 

This question is related to javascript google-analytics

The answer is


From the docs:

_trackTrans() Sends both the transaction and item data to the Google Analytics server. This method should be called after _trackPageview(), and used in conjunction with the _addItem() and addTrans() methods. It should be called after items and transaction elements have been set up.

So, according to the docs, the items get sent when you call trackTrans(). Until you do, you can add items, but the transaction will not be sent.

Edit: Further reading led me here:

http://www.analyticsmarket.com/blog/edit-ecommerce-data

Where it clearly says you can start another transaction with an existing ID. When you commit it, the new items you listed will be added to that transaction.