Ecommerce Tracking - iOS SDK

This document provides an overview of how to measure in-app payments and revenue using the Google Analytics SDK for iOS v2.

  1. Overview
  2. Implementation
    1. Currency Types
  • Related Documents

  • Platform

  • Reference: Ecommerce Learn about the ecommerce data model, measurement, and reporting options.
  • Collection

  • Web Tracking: analytics.js Using custom dimensions and metrics on the web with the analytics.js library.
  • Android SDK Measuring in-app payments and ecommerce in native Android apps with the Google Analytics SDK for Android.
  • iOS SDK Measuring in-app payments and ecommerce in native Android apps with the Google Analytics SDK for iOS.
  • Measurement Protocol Measuring ecommerce activity in almost any environment using the measurement protocol.
  • Configuration

  • Setting Global Currency (Help Center) Learn how to set the global currency of a view (profile).
  • Related Topics

  • Supported Currency Codes Learn which currency codes are supported for measuring local currencies."


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 transacation ID. In the Google Analytics SDK for iOS, 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:.

In the following example, we assume that onPurchaseCompleted is called after the user has completed an in-app purchase.

- (void)onPurchaseCompleted {
  GAITransaction *transaction =
      [GAITransaction transactionWithId:@"0_123456"            // (NSString) Transaction ID, should be unique.
                        withAffiliation:@"In-App Store"];      // (NSString) Affiliation
  transaction.taxMicros = (int64_t)(0.17 * 1000000);           // (int64_t) Total tax (in micros)
  transaction.shippingMicros = (int64_t)(0);                   // (int64_t) Total shipping (in micros)
  transaction.revenueMicros = (int64_t)(2.16 * 1000000);       // (int64_t) Total revenue (in micros)

  [transaction addItemWithSKU:@"L_789"                         // (NSString) Product SKU
                         name:@"Level Pack: Space"             // (NSString) Product name
                     category:@"Game expansions"               // (NSString) Product category
                  priceMicros:(int64_t)(1.99 * 1000000)        // (int64_t)  Product price (in micros)
                     quantity:1];                              // (NSInteger)  Product quantity

  [[GAI sharedInstance].defaultTracker sendTransaction:transaction]; // Send the transaction.

Currency Types

In the Google Analytics SDK for iOS, 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.

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.