Hello All,
currently i have google ecommerce tracking code enabled in my website. i want to track the productNo and ProductNames along with their prices.
this where i am stuck. my shopping cart where i put the tracking code can have more then one itemNo.
i used a loop to the cart to display the items but the tracking code wont display any product information. if i do a view source of the page all i see is
its display the order id like A001 but for the rest it just displays the code like grid.rows.cells[0].innerText instead of the item no and so on
My site is built in ASP.NET2.0 and C#. here is my code for the tracking.
<!-- using Gridview to bind the cart details -->
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None">
</asp:GridView>
GridView1.DataSource = HttpContext.Current.Items["cartDetails"];
GridView1.DataBind();
<!-- now i am using this gridview information in my tracking code as follow -->
<!-- google analytics code -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("XX-XXXXXXX-X");
pageTracker._trackPageview();
pageTracker._addTrans(
"<% =lOrderId.Text %>", // order id
"<% =lBillingName.Text %>", // affliation
"<% =lTotal.Text %>", // total
"",
"",
"",
"",
"");
var grid = document.getElementById('<%= GridView1.ClientID %>');
for (i = 1; i < grid.rows.length; i++)
{
pageTracker._addItem(
"<% =lOrderId.Text %>", // order id
grid.rows[i].cells[0].innerText, // item no
grid.rows[i].cells[1].innerText, // price
grid.rows[i].cells[2].innerText,// product title
grid.rows[i].cells[3].innerText,// size
"");
}
pageTracker._trackTrans();
} catch(err) {}</script>
can someone please help out how to fix the code so i can track the item details.
Appreciate it.