What you want to do here is run through a foreach loop.
For example (untested):
PHP Code:
function initTracking () {ldelim}
{foreach from=$orders.0.products item=prod} /* This gets the products array from the order, and assigns each to a new variable named "prod"*/
try {ldelim} Tracking.getProduct('UA-XXXX','{$prod.productid}').logAddTo Cart(); {rdelim} catch (e) {ldelim}{rdelim}
{/foreach}
{rdelim}
Just so you understand better how loops work, consider this annotated code:
PHP Code:
{foreach from=$orders item=order} /* Start a foreach loop through the orders array and assign to new variable order */
{foreach from=$order.products item=product} /* Uses the newly assigned $order variable and accesses its sub-array called products to start a new loop with each instance named product /*
{$product.productid} /* Prints the product id for the current product from the current order */
{/foreach} /* closes the products loop */
{/foreach} /* closes the orders loop */
The above example should print each product from each order. It will print all the products from the first order, then all the products from the second order, and so on.