Is there any issue in this google ecommerce code. We had tons of transactions but none showing up in the ecommerce...
<script type="text/javascript">
try{
var pageTracker = _gat._getTracker("UA-XXXXXX-1");
pageTracker._trackPageview();
pageTracker._addTrans(
"429", // order ID - required
"louiseh", // affiliation or store name
"11.65", // total - required
"3.15", // shipping
"Santa Clara", // city
"California", // state or province
);
//Add each items in the order
pageTracker._addItem(
"429", // order ID - necessary to associate item with transaction
"99", // SKU/code - required
"Sandwich WrapIt!", // product name
"Home, Garden & Pets", // category or variation
"8.5", // unit price - required
"1",
开发者_JAVA百科 );
//Now submit the transaction
pageTracker._trackTrans(); //submits transaction to the Analytics server
} catch(err) {}
</script>
<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("UA-xxxxx-1");
pageTracker._trackPageview();
} catch(err) {}</script>
The ecommerce code is being executed before the ga.js
script is loaded so the _gat
object isn't available yet. An error is being thrown but it's not being shown in the error console because it's enclosed in a try/catch
block. If you reorder the script blocks then it should work:
<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("UA-XXXXXX-1");
pageTracker._trackPageview();
pageTracker._addTrans(
"429", // order ID - required
"louiseh", // affiliation or store name
"11.65", // total - required
"3.15", // shipping
"Santa Clara", // city
"California" // state or province
);
//Add each items in the order
pageTracker._addItem(
"429", // order ID - necessary to associate item with transaction
"99", // SKU/code - required
"Sandwich WrapIt!", // product name
"Home, Garden & Pets", // category or variation
"8.5", // unit price - required
"1"
);
//Now submit the transaction
pageTracker._trackTrans(); //submits transaction to the Analytics server
} catch(err) {}
</script>
精彩评论