Urchin ELF2 Ecommecre Log File Helper

Hello,

I am currently needing to implement ecommerce tracking with our Urchin stats server. To do this it reads your transaction logs that you write to when users buy from your site. This file needs to be in a special format ELF2 click here for more info.

I though I would write some helper classes to make writing my ELF2 logs easier and something that would be reusable and could even have functionality added in the future to parse the logs (most likely never needed but you never know). So I created a set of classes to do this for me. I will not post the source code right now but if there is interest will tidy it up and release it for all too use.

Adding a new order to a transaction record to your log is as easy as pie:

ELF2TransactionLog log = new ELF2TransactionLog();

log.TransactionLines.Add(new ELF2LogTransactionLine() {
                OrderID = "100",
                RemoteHost = "GETIPHERE",
                UserAgent = Request.ServerVariables["HTTP_USER_AGENT"].ToString(),
                Store = "My Store",
                SessionID = "000-111",             
               
Total = 895,
                Tax = 10,
                Shipping = 10,
                BillCity = "Perth",
                BillState = "WA",
                BillZip = "6025",
                BillCountry = "Australia",
                Cookies = "GETCOOKIESHERE :)",
                LineItems = {
                    new ELF2LogTransactionItemLine() {
                        OrderID = "100",  
                       
ProductCode = "test1",
                        ProductName = "Test Product 1",
                        Variation = "",
                        Price = 100M,
                        Quantity = 1,
                        UpSold = false,
                        UserAgent = Request.ServerVariables["HTTP_USER_AGENT"].ToString(),
                        Cookies = "GETCOOKIESHERE",
                        RemoteHost = "GETIPHERE"
                    }
                }
            });

log.Save(Server.MapPath("~/biglog.log"), true);


Thanks
Stefan
 

No Comments