Code:
<?xml version="1.0" standalone="yes" ?>
<package version="2.1" displayname="Analytics" debug="false" includeentityhelper="false">
<query name="Order" rowElementName="OrderInfo">
<sql>
<![CDATA[
select o.*, (case when o.AffiliateID = 0
then 'None' else (select a.Name from dbo.Affiliate a with (NOLOCK) where a.AffiliateID = o.AffiliateID) end) as AffiliateName From dbo.orders o with (NOLOCK)
where o.ordernumber = @ordernum
]]>
</sql>
<queryparam paramname="@ordernum" paramtype="request" requestparamname="ordernumber" defvalue="0" sqlDataType="int" validationpattern="^\d{1,9}$"/>
</query>
<query name="OrderItems" rowElementName="Item">
<sql>
<![CDATA[
SELECT s.ShoppingCartRecID,
s.OrderNumber,
s.ProductID,
s.VariantID,
s.Quantity,
s.ChosenColor,
s.ChosenSize,
s.OrderedProductName,
s.OrderedProductVariantName,
s.OrderedProductSKU,
s.OrderedProductPrice,
s.OrderedProductRegularPrice,
s.OrderedProductSalePrice,
s.OrderedProductExtendedPrice,
s.OrderedProductQuantityDiscountName,
s.OrderedProductQuantityDiscountID,
s.OrderedProductQuantityDiscountPercent,
s.IsShipSeparately,
s.IsDownload,
s.FreeShipping,
s.TextOption,
s.ShippingMethod,
s.Notes,
s.ExtensionData,
s.CustomerEntersPrice,
s.GiftRegistryForCustomerID,
s.ShippingAddressID,
s.ShippingDetail,
s.SizeOptionPrompt,
s.ColorOptionPrompt,
s.TextOptionPrompt,
s.IsTaxable,
s.TaxClassID,
s.TaxRate,
ISNULL(s.IsAKit, 0) AS IsAKit,
ISNULL(s.IsAPack, 0) AS IsAPack,
ISNULL(s.IsSystem, 0) AS IsSystem
FROM dbo.Orders_ShoppingCart s WITH (NOLOCK)
WHERE s.ordernumber = @ordernum
ORDER by s.ShippingAddressID
]]>
</sql>
<queryparam paramname="@ordernum" paramtype="request" requestparamname="ordernumber" defvalue="0" sqlDataType="int" validationpattern="^\d{1,9}$"/>
</query>
<PackageTransform>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:aspdnsf="urn:aspdnsf" exclude-result-prefixes="aspdnsf">
<xsl:output method="html" omit-xml-declaration="yes"/>
<xsl:variable name="OrderNumber" select="/root/Order/OrderInfo/OrderNumber" />
<xsl:template match="/">
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '<xsl:value-of select="aspdnsf:AppConfig('Google.AnalyticsAccount')" disable-output-escaping="yes"/>']);
_gaq.push(['_trackPageview']);
<xsl:if test="/root/Runtime/PageName = 'orderconfirmation.aspx'">
_gaq.push(['_addTrans',
'<xsl:value-of select="$OrderNumber" />',
'<xsl:value-of select="/root/Order/OrderInfo/AffiliateName" />',
'<xsl:value-of select="format-number(/root/Order/OrderInfo/OrderTotal, '0.00')" />',
'<xsl:value-of select="format-number(/root/Order/OrderInfo/OrderTax, '0.00')" />',
'<xsl:value-of select="format-number(/root/Order/OrderInfo/OrderShippingCosts, '0.00')" />',
'<xsl:value-of select="/root/Order/OrderInfo/BillingCity" />',
'<xsl:value-of select="/root/Order/OrderInfo/BillingState" />',
'<xsl:value-of select="/root/Order/OrderInfo/BillingCountry" />'
]);
<xsl:apply-templates select="/root/OrderItems/Item" />
_gaq.push(['_trackTrans']);
</xsl:if>
(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>
</xsl:template>
<xsl:template match="Item">
_gaq.push(['_addItem',
'<xsl:value-of select="OrderNumber" />',
'<xsl:value-of select="OrderedProductSKU" />',
'<xsl:value-of select="OrderedProductName" />',
'', // category or variation - could add color or size here
'<xsl:value-of select="format-number(OrderedProductPrice div Quantity, '0.00')" />',
'<xsl:value-of select="Quantity" />'
]);
</xsl:template>
</xsl:stylesheet>
</PackageTransform>
</package>