Ecommerce measurement allows you to send in-app purchases and sales to Google Analytics. Ecommerce data in Google Analytics is generally comprised of transactions and items, related by a shared transaction ID. In the Google Analytics SDK for Windows 8 and Windows Phone, that relationship is established by creating a transaction object and adding items to it.

Ecommerce data is used primary in the following reports:
  • Ecommerce Overview
  • Product Performance
  • Sales Performance
  • Transactions
  • Time to Purchase


There are three steps to measure a transaction with Google Analytics:
  1. Build a transaction object.
  2. Build item objects and add them to the transaction object.
  3. Send the transaction using SendTransaction(Transaction transObject) .

In the following example, we assume that onPurchaseCompleted() is called after the user has completed an in-app purchase.
/// <summary>
/// The purchase was processed. We will send the transaction and its associated line items to Google Analytics,
/// but only if the purchase has been confirmed.
/// </summary>
public void onPurchaseCompleted()
    Transaction myTrans = new Transaction(
        "0_123456", // (string) Transaction Id, should be unique.
        (long)(2.16 * 1000000)) // (long) Order total (in micros)
            Affiliation = "In-App Store", // (string) Affiliation
            TotalTaxInMicros = (long)(0.17 * 1000000), // (long) Total tax (in micros)
            ShippingCostInMicros = 0 // (long) Total shipping cost (in micros)

    myTrans.Items.Add(new TransactionItem(
        "L_789", // (string) Product SKU
        "Level Pack: Space", // (string) Product name
        (long)(1.99 * 1000000), // (long) Product price (in micros)
        (long)1) // (long) Product quantity
            Category = "Game expansions" // (string) Product category

    Tracker myTracker = EasyTracker.GetTracker(); // Get reference to tracker.
    myTracker.SendTransaction(myTrans); // Send the transaction.

Currency Types

In the Google Analytics SDK for Windows 8 and Windows Phone , Ecommerce currency fields must be in micros (millionths of currency).

For example, to send a currency value of 4.5991, you should convert that value to micros (i.e. 4599100) when you send the transaction to Google Analytics, as in the examples above. When the SDK dispatches that transaction to Google Analytics, that value is automatically converted into a fixed-point decimal value and sent as 4.5991.
Note: While you must convert your currencies into micros, under the hood the SDK sends the currency data to Google Analytics using fixed-point decimal values. This ensures that precision is not lost across various currencies.

Currency symbols should not be included in your Ecommerce code, nor should commas be used.

Ecommerce currency fields also support negative currency values, as may be necessary in the case of refunds or returns.

Specifying Currencies

By default, transaction values are assumed to be in the currency of the profile in which they are reported.

To override the local currency of a transaction, call setCurrencyCode when building a Transaction as in the following example:
/// <summary>
/// In this example, the currency of the transaction is set to Euros. The
/// currency values will appear in reports using the global currency
/// type of the profile.
/// </summary>
public void onPurchaseCompleted()
    Transaction myTrans = new Transaction(
        (long)(1.59 * 1000000))
            Affiliation = "In-App Store",
            TotalTaxInMicros = (long)(0.13 * 1000000),
            ShippingCostInMicros = 0,
            CurrencyCode = "EUR" // (String) Set currency code to Euros.

    Tracker myTracker = EasyTracker.GetTracker();

For the complete list of supported currencies and currency codes, see the Supported Currencies Reference.

Last edited Apr 13, 2013 at 9:47 PM by timgreenfield, version 2