At work, we are using Google Analytics tool to monitor user behaviour on our web pages. One of the things we really desired in earlier versions and is now finally available is e-commerce transaction logging. This extension uses passed data in many cool ways, creating several impressive reports (e.g. how many times a user visited our page prior making purchase).

Documentation on transaction logging implementation can be found here. There is a slight error in documentation (applies before this post was published). When adding an Item, first parameter is not Item number, but Transaction Id! Well, if you want your reports to behave like they should according to specifications.

Anyway, to cut a long story short. I created a set of custom classes that will help you implement GA e-commerce code into LotusScript. It is compatible with Google Analytics e-commerce Documentation, meaning that optional parameters are optional in this class as well.

How to install?

First, you need to download this file to your computer and unzip it. Create a LotusScript library in destination database. Choose File->Import and select extracted file.  Save and close the library.

How to test?
Here is my testing code from an agent:

Use "GoogleAnalytics" 'GA script library

Dim ga As New CGoogleAnalytics
Dim trans As New CGATransaction
Dim item As New CGAItem

trans.OrderId = "1234"
trans.Affiliation = "Test store"
trans.Total = "20.00"
trans.Tax = "4.00"
trans.Shipping = "0.00"
trans.City = "Ljubljana"
trans.State = "SI"
trans.Country = "Slovenia"

'item 1
item.OrderId = trans.OrderId
item.SKU = "ItemSKU"
item.ItemName = "ItemName1"
item.Category = "ItemCategory1"
item.Price = "5.00"
item.Quantity = "1"
Call trans.AddItem (item)

'item 2
item.OrderId = trans.OrderId
item.SKU = "ItemSKU"
item.ItemName = "ItemName2"
item.Category = "ItemCategory2"
item.Price = "15.00"
item.Quantity = "1"
Call trans.AddItem (item)

'Debug parameter is added only for testing purposes.
'Default is false. If true, it strips script tags from output.
ga.Debug = True
Set ga.Transaction = trans
Messagebox ga.Serialize ("SiteName")