Part 1: URCHIN
Use the following Analytics tracking code in your skin template.ascx file(s):
Code:
<script src="https://ssl.google-analytics.com/urchin.js"
type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-XXXXX-X";
urchinTracker();
</script>
Please note also that the "UA-XXXXX-X" value should be replaced with your account number.
Note the use of HTTPS and different url. This avoids the browser security warning pop-up message on every secure page. This HTTPS link can also be invoked on non-secure pages also, so embedding in the skin is fine. We place this in template.ascx just before the closing body tag.
You must sign up for a Google Urchin account first of course. Note that stats reporting into google can often be delayed a bit (up to 1 DAY), so once you first add this to your skin template, it will NOT show up that very second...give it a day to ensure it's working.
PART 2 (optional)
To Track "e-commerce transactions", see:
http://adwords.google.com/support/bi...y?answer=55528
For assistance, please see Google. Some notes are below:
a) make sure you setup your site as e-commerce site as "yes"
b) use https://www.yourdomain.com/orderconfirmation.aspx as the sales goal page
c) (optional) use your own checkout page sequence as your goal funnel. All sites are different. Examples are shoppingcart.aspx -> createaccount.aspx -> checkoutshipping.aspx -> checkoutpayment.aspx -> checkoutreview.aspx -> orderconfirmation.aspx, or shoppingcart.aspx -> checkout1.aspx -> orderconfirmation.aspx. If you are skipping shipping it's different, etc.
d) (note) the urchin tracker code will ALREADY be in your orderconfirmation pages and checkout pages if you did the PART 1 steps above! do not repeat this on the orderconfirmation page.
e) add this new parser tag just below the urchin javascript block in your template.ascx file:
(!GOOGLE_ECOM_TRACKING!)
That's it. This will be in fully supported (included in the core dll's) in builds 7.0.1.0+.
PRIOR VERSION USERS
For prior version users, you have to also make some code mods to add this:
1. change the order.cs object to have the m_AffiliateID to be of type int (not string).
2. add these new changes to order.cs:
Code:
public int AffiliateID
{
get
{
return m_AffiliateID;
}
}
public String AffiliateName
{
get
{
String tmpS = String.Empty;
if (AffiliateID > 0)
{
EntityHelper AffiliateHelper = AppLogic.LookupHelper(EntityDefinitions.readonly_AffiliateEntitySpecs.m_EntityName);
tmpS = AffiliateHelper.GetEntityName(AffiliateID, Localization.GetWebConfigLocale());
}
return tmpS;
}
}
3. Add this new Parser Token in Parser.cs:ReplacePageDynamicTokens:
Code:
if (s.IndexOf("(!GOOGLE_ECOM_TRACKING!)") != -1)
{
if (CommonLogic.GetThisPageName(false).ToLowerInvariant().StartsWith("orderconfirmation.aspx"))
{
ht.Add("GOOGLE_ECOM_TRACKING", AppLogic.GetGoogleEComTracking(ThisCustomer));
}
else
{
ht.Add("GOOGLE_ECOM_TRACKING", String.Empty);
}
}
4. Add this new routine in AppLogic.cs:
Code:
public static String GetGoogleEComTracking(Customer ThisCustomer)
{
if (!AppLogic.AppConfigBool("UseLiveTransactions") || ThisCustomer == null || !CommonLogic.GetThisPageName(false).ToLowerInvariant().StartsWith("orderconfirmation.aspx") || CommonLogic.QueryStringUSInt("OrderNumber") == 0)
{
return String.Empty;
}
try
{
int OrderNumber = CommonLogic.QueryStringUSInt("OrderNumber");
Order ord = new Order(OrderNumber, Localization.GetWebConfigLocale());
if (ThisCustomer.CustomerID != ord.CustomerID)
{
return String.Empty;
}
StringBuilder tmpS = new StringBuilder(1024);
tmpS.Append("<form style=\"display:none;\" name=\"utmform\">\n");
tmpS.Append("<textarea id=\"utmtrans\">\n");
tmpS.Append(String.Format(" UTM:T|{0}|{1}|{2}|{3}|{4}|{5}|{6}|{7} \n",
ord.OrderNumber.ToString(),
ord.AffiliateName,
Localization.CurrencyStringForGatewayWithoutExchangeRate(ord.Total(true)),
Localization.CurrencyStringForGatewayWithoutExchangeRate(ord.TaxTotal(true)),
Localization.CurrencyStringForGatewayWithoutExchangeRate(ord.ShippingTotal(true)),
ord.BillingAddress.m_City,
ord.BillingAddress.m_State,
ord.BillingAddress.m_Country
));
foreach(CartItem c in ord.CartItems)
{
tmpS.Append(String.Format(" UTM:I|{0}|{1}|{2}|{3}|{4}|{5} \n",
ord.OrderNumber.ToString(),
c.m_SKU,
c.m_ProductName,
AppLogic.GetFirstProductEntity(AppLogic.LookupHelper(EntityDefinitions.readonly_CategoryEntitySpecs.m_EntityName),c.m_ProductID,false,Localization.GetWebConfigLocale()),
Localization.CurrencyStringForGatewayWithoutExchangeRate(c.m_Price),
c.m_Quantity.ToString()
));
}
tmpS.Append("</textarea>");
tmpS.Append("</form>\n");
tmpS.Append("<script type=\"text/javascript\">__utmSetTrans();</script>");
return tmpS.ToString();
}
catch
{
return String.Empty;
}
}
5. Recompile and test/deploy.
Again, these code mods will be in build 7.0.1.0+ automatically. You just have to add the (!GOOGLE_ECOM_TRACKING!) token to your skin file.