Answers Events

Answers Events gives you the ability to track the specific actions and events in your app that matter most. You can now see how users are behaving in your app and surfacing that critical information in real-time. There are a set of core events that developers let us know that they wanted to track in addition to the existing Answers’ metrics, so we built out a set of events such as “Content Viewed”, “Purchase”, or “Level Start”, in addition to many others that you can find below.

All of the events have a number of optional, but recommended parameters, to help you better understand your user’s behavior within your app. We also realize that every app has their own unique user actions to track, which you can do using custom events. Answers can track a maximum of 3,000 distinct events per app. For example, logPurchaseWithPrice and logStartCheckout would be two of your 3,000 events. Each of those events can be logged without any limits.

You can also add your own custom attributes to any event. Each specific logged event can have a maximum of 20 attributes per event call. For example, you can log logPurchaseWithPrice with up to 20 custom attributes per call, but those attributes do not need to be the same for each call. The Answers’ web dashboard can show a maximum of 50 custom attributes per event.

Note

If you’re a legacy Crashlytics customer, to ensure you have access to Answers Events, upgrade to the latest version of Crashlytics Kit.

Event Types

Purchase

Implementing a Purchase event allows you to see your revenue in real-time, understand how many users are making purchases, see which items are most popular, and track plenty of other important purchase-related metrics.

// Objective-C
[Answers logPurchaseWithPrice:[NSDecimalNumber decimalNumberWithString:@"13.50"]
                      currency:@"USD"
                      success:@YES
                      itemName:@"Answers Shirt"
                      itemType:@"Apparel"
                      itemId:@"sku-350"
                      customAttributes:@{}];

// Swift
Answers.logPurchaseWithPrice(13.50,
                      currency: "USD",
                      success: true,
                      itemName: "Answers Shirt",
                      itemType: "Apparel",
                      itemId: "sku-350",
                      customAttributes: nil)

Currencies

Purchase events, Start Checkout events, and Add to Cart events have currencies converted to equivalent USD value from their local currency. For Purchase events and Add to Cart events, we convert the value for the itemPrice. For Start Checkout events, we convert the value of totalPrice.

This conversion uses a daily snapshot of these currency conversions. We support the following ISO4217 currency codes:

ISO4217 Currency Code Currency Name
AED United Arab Emirates Dirham
AFN Afghanistan Afghani
ALL Albania Lek
AMD Armenia Dram
ANG Netherlands Antilles Guilder
AOA Angola Kwanza
ARS Argentina Peso
AUD Australia Dollar
AWG Aruba Guilder
AZN Azerbaijan New Manat
BAM Bosnia and Herzegovina Convertible Marka
BBD Barbados Dollar
BDT Bangladesh Taka
BGN Bulgaria Lev
BHD Bahrain Dinar
BIF Burundi Franc
BMD Bermuda Dollar
BND Brunei Darussalam Dollar
BOB Bolivia Bolíviano
BRL Brazil Real
BSD Bahamas Dollar
BTC Bitcoin
BTN Bhutan Ngultrum
BWP Botswana Pula
BYR Belarus Ruble
BZD Belize Dollar
CAD Canada Dollar
CDF Congo/Kinshasa Franc
CHF Switzerland Franc
CLP Chile Peso
CNY China Yuan Renminbi
COP Colombia Peso
CRC Costa Rica Colon
CUC Cuba Convertible Peso
CUP Cuba Peso
CVE Cape Verde Escudo
CZK Czech Republic Koruna
DJF Djibouti Franc
DKK Denmark Krone
DOP Dominican Republic Peso
DZD Algeria Dinar
EGP Egypt Pound
ERN Eritrea Nakfa
ETB Ethiopia Birr
EUR Euro Member Countries
FJD Fiji Dollar
FKP Falkland Islands (Malvinas) Pound
GBP United Kingdom Pound
GEL Georgia Lari
GHS Ghana Cedi
GIP Gibraltar Pound
GMD Gambia Dalasi
GNF Guinea Franc
GTQ Guatemala Quetzal
GYD Guyana Dollar
HKD Hong Kong Dollar
HNL Honduras Lempira
HRK Croatia Kuna
HTG Haiti Gourde
HUF Hungary Forint
IDR Indonesia Rupiah
ILS Israel Shekel
INR India Rupee
IQD Iraq Dinar
IRR Iran Rial
ISK Iceland Krona
JMD Jamaica Dollar
JOD Jordan Dinar
JPY Japan Yen
KES Kenya Shilling
KGS Kyrgyzstan Som
KHR Cambodia Riel
KMF Comoros Franc
KPW Korea (North) Won
KRW Korea (South) Won
KWD Kuwait Dinar
KYD Cayman Islands Dollar
KZT Kazakhstan Tenge
LAK Laos Kip
LBP Lebanon Pound
LKR Sri Lanka Rupee
LRD Liberia Dollar
LSL Lesotho Loti
LYD Libya Dinar
MAD Morocco Dirham
MDL Moldova Leu
MGA Madagascar Ariary
MKD Macedonia Denar
MMK Myanmar (Burma) Kyat
MNT Mongolia Tughrik
MOP Macau Pataca
MRO Mauritania Ouguiya
MUR Mauritius Rupee
MVR Maldives (Maldive Islands) Rufiyaa
MWK Malawi Kwacha
MXN Mexico Peso
MYR Malaysia Ringgit
MZN Mozambique Metical
NAD Namibia Dollar
NGN Nigeria Naira
NIO Nicaragua Cordoba
NOK Norway Krone
NPR Nepal Rupee
NZD New Zealand Dollar
OMR Oman Rial
PAB Panama Balboa
PEN Peru Sol
PGK Papua New Guinea Kina
PHP Philippines Peso
PKR Pakistan Rupee
PLN Poland Zloty
PYG Paraguay Guarani
QAR Qatar Riyal
RON Romania New Leu
RSD Serbia Dinar
RUB Russia Ruble
RWF Rwanda Franc
SAR Saudi Arabia Riyal
SBD Solomon Islands Dollar
SCR Seychelles Rupee
SDG Sudan Pound
SEK Sweden Krona
SGD Singapore Dollar
SHP Saint Helena Pound
SLL Sierra Leone Leone
SOS Somalia Shilling
SRD Suriname Dollar
STD São Tomé and Príncipe Dobra
SVC El Salvador Colon
SYP Syria Pound
SZL Swaziland Lilangeni
THB Thailand Baht
TJS Tajikistan Somoni
TMT Turkmenistan Manat
TND Tunisia Dinar
TOP Tonga Pa’anga
TRY Turkey Lira
TTD Trinidad and Tobago Dollar
TVD Tuvalu Dollar
TWD Taiwan New Dollar
TZS Tanzania Shilling
UAH Ukraine Hryvnia
UGX Uganda Shilling
USD United States Dollar
UYU Uruguay Peso
UZS Uzbekistan Som
VEF Venezuela Bolivar
VND Viet Nam Dong
VUV Vanuatu Vatu
WST Samoa Tala
XAF Communauté Financière Africaine (BEAC) CFA Franc BEAC
XCD East Caribbean Dollar
XOF Communauté Financière Africaine (BCEAO) Franc
XPF Comptoirs Français du Pacifique (CFP) Franc
YER Yemen Rial
ZAR South Africa Rand
ZMW Zambia Kwacha
ZWD Zimbabwe Dollar

Add to Cart

Implementing an Add to Cart event allows you to see users adding items to a shopping cart in real-time, understand how many users start the purchase flow, see which items are most popular, and track plenty of other important purchase-related metrics.

// Objective-C
[Answers logAddToCartWithPrice:[NSDecimalNumber decimalNumberWithString:@"13.50"]
                      currency:@"USD"
                      itemName:@"Answers Shirt"
                      itemType:@"Apparel"
                      itemId:@"sku-350"
                      customAttributes:@{}];

// Swift
Answers.logAddToCartWithPrice(13.50,
                      currency: "USD",
                      itemName: "Answers Shirt",
                      itemType: "Apparel",
                      itemId: "sku-350",
                      customAttributes: nil)

Recommended Attributes

We recommend including the following attributes to get a better understanding of your users’ activity related to adding items to a shopping cart within your app. These are all optional, and included in the example above.

  • itemPrice The item’s amount in the currency specified
  • currency The ISO4217 currency code
  • itemName The human-readable name for the item
  • itemType The category the item falls under
  • itemId A unique identifier used to track the item

Note

See the Currencies section for more details on how we convert total prices by currency.

Start Checkout

Implementing a Start Checkout event allows you to see users moving through the purchase funnel in real-time, understand how many users are doing this and how much they’re spending per checkout, and see how it related to other important purchase-related metrics.

// Objective-C
[Answers logStartCheckoutWithPrice:[NSDecimalNumber decimalNumberWithString:@"13.50"]
                      currency:@"USD"
                      itemCount:@3
                      customAttributes:@{}];

// Swift
Answers.logStartCheckoutWithPrice(13.50,
                      currency: "USD",
                      itemCount: 3,
                      customAttributes: nil)

Recommended Attributes

We recommend including the following attributes to get a better understanding of your users’ activity related to starting checkout within your app. These are all optional, and included in the example above.

  • totalPrice The total price of all items in cart in the currency specified
  • currency The ISO4217 currency code
  • itemCount The count of items in cart

Note

See the Currencies section for more details on how we convert total prices by currency.

Content View

Implementing a Content View event allows you to see users viewing content within your app in real-time and understand what content is most engaging, from the type or genre down to the specific id.

// Objective-C
[Answers logContentViewWithName:@"Answers setup process super easy!"
                      contentType:@"Technical documentation"
                      contentId:@"article-350"
                      customAttributes:@{}];

// Swift
Answers.logContentViewWithName("Answers setup process super easy!",
                      contentType: "Technical documentation",
                      contentId: "article-350",
                      customAttributes: nil)

Recommended Attributes

We recommend including the following attributes to get a better understanding of your users’ activity related to viewing content within your app. These are all optional, and included in the example above.

  • contentName The Human-readable name of content
  • contentType The category your item falls under
  • contentId A unique identifier used to track the item

Share

Implementing a Share event allows you to see users sharing from your app in real-time, letting you understand what content they’re sharing from the type or genre down to the specific id.

// Objective-C
[Answers logShareWithMethod:@"Twitter"
                      contentName:@"Answers named #2 in Mobile Analytics"
                      contentType:@"tweet"
                      contentId:@601072000245858305
                      customAttributes:@{}];

// Swift
Answers.logShareWithMethod("Twitter",
                      contentName: "Answers named #2 in Mobile Analytics",
                      contentType: "tweet",
                      contentId: "601072000245858305",
                      customAttributes: nil)

Recommended Attributes

We recommend including the following attributes to get a better understanding of your users’ activity related to sharing. These are all optional, and included in the example above.

  • method The method used to share content
  • contentName The description of the content
  • contentType The type or genre of content
  • contentId A unique key identifying the content

Rated Content

Implementing a Rated Content event allows you to see users rating content within your app in real-time and understand what content is most engaging, from the type or genre down to the specific id.

// Objective-C
[Answers logRating:@4
            contentName:@"Answers setup process super easy!"
            contentType:@"Technical documentation"
            contentId:@"article-350"
            customAttributes:@{}];

// Swift
Answers.logRating(4,
            contentName: "Answers setup process super easy!",
            contentType: "Technical documentation",
            contentId: "article-350",
            customAttributes: nil)

Recommended Attributes

We recommend including the following attributes to get a better understanding of your users’ activity related to rating content within your app. These are all optional, and included in the example above.

  • rating An integer rating of the content
  • contentName The human-readable name of content
  • contentType The category your item falls under
  • contentId A unique identifier used to track the item

Sign Up

Implementing a Sign Up event allows you to see users signing up for your app in real-time, understand how many users are signing up with different methods and their success rate signing up.

// Objective-C
[Answers logSignUpWithMethod:@"Digits"
                      success:@YES
                      customAttributes:@{}];

// Swift
Answers.logSignUpWithMethod("Digits",
                      success: true,
                      customAttributes: nil)

Recommended Attributes

We recommend including the following attributes to get a better understanding of your users’ activity related to sign up. These are all optional, and included in the example above.

  • method The method used to sign up
  • success Whether sign up succeeded or failed

Log In

Implementing a Log In event allows you to see users logging into your app in real-time, understand how many users are logging in with different methods and their success rate logging into your app.

// Objective-C
[Answers logLoginWithMethod:@"Digits"
                      success:@YES
                      customAttributes:@{}];

// Swift
Answers.logLoginWithMethod("Digits",
                      success: true,
                      customAttributes: nil)

Recommended Attributes

We recommend including the following attributes to get a better understanding of your users’ activity related to login. These are all optional, and included in the example above.

  • method The method used to sign up
  • success Whether sign up succeeded or failed

Invite

Implementing an Invite event allows you to see existing users inviting other users and growing your user base in real-time, letting you understand which methods are the most successful.

// Objective-C
[Answers logInviteWithMethod:@"Twitter"
                      customAttributes:@{}];

// Swift
Answers.logInviteWithMethod("Twitter",
                      customAttributes: nil)

Recommended Attributes

We recommend including the following attributes to get a better understanding of your users’ activity related to inviting other users. These are all optional, and included in the example above.

  • method The method used to invite the user

Level Start

Implementing an Level Start event allows you to see users starting levels in real-time, letting you understand which levels see the most action.

// Objective-C
[Answers logLevelStart:@"Level 2A"
                      customAttributes:@{}];

// Swift
Answers.logLevelStart("Level 2A",
                      customAttributes: nil)

Recommended Attributes

We recommend including the following attributes to get a better understanding of your users’ activity related to starting levels within your app. These are all optional, and included in the example above.

  • levelName String key describing the level

Level End

Implementing a Level End event allows you to see users finishing levels in real-time, letting you understand which levels see the most action, and see the scores users are achieving.

// Objective-C
[Answers logLevelEnd:@"Level 2A"
                      score:@350
                      success:@YES
                      customAttributes:@{}];

// Swift
Answers.logLevelEnd("Level 2A",
                      score: 350,
                      success: true,
                      customAttributes: nil)

Recommended Attributes

We recommend including the following attributes to get a better understanding of your users’ activity related to finishing levels within your app. These are all optional, and included in the example above.

  • levelName The string key describing the level
  • score The score for this level
  • success Completed the level or failed trying

Custom Event

To log a custom event to be sent to Answers, use the following:

// Objective-C
[Answers logCustomEventWithName:@"My First Custom Event"
                      customAttributes:@{}];

// Swift
Answers.logCustomEventWithName("My First Custom Event",
                      customAttributes: nil)

You can also include a series of custom attributes to get even deeper insight into what’s happening in your app.

Custom Attributes

In addition to the recommended attributes for each event, you can also add custom attributes for any event. To log an event with a custom attribute, use the following:

// Objective-C
[Answers logCustomEventWithName:@"My First Custom Event"
                      customAttributes:@{
                          @"Custom String" : @"foo",
                          @"Custom Number" : @35}];
// Swift
Answers.logCustomEventWithName("My First Custom Event",
                      customAttributes: [
                          "Custom String": "foo",
                          "Custom Number": 35])

A couple of things to know on how we treat NSNumbers and NSStrings which are the two supported types of attributes.

NSNumbers As this data is collected, you will see the distribution of values over time.

NSStrings NSStrings are used as categorical data so that you can compare the data across the different values. The maximum length of each string is 100 characters.

Set KPI Events

Answers allows you to set KPIs (Key Performance Indicators) to highlight events that are the most important to your app. One KPI Event can be set per app.

To set a KPI, navigate to the Events tab on your Answers dashboard and select an Event.

../_images/set-kpi.gif

After setting a KPI, it appears at the top of your Events list and on your app’s Mission Control summary card on https://www.fabric.io/home.

Troubleshooting

Too Many Event Types

If an app hits the limit of 3,000 maximum unique event types, you should be able to represent your data better using Custom Attributes. After that, once we receive fewer than 3,000 unique event types in a single day for your app, we will start processing all of your events again.

An example where Custom Attributes could help is when the event type is set using a variable string value that can have many different values:

// Objective-C
- (void) logArticleShared:(NSString *)url {
    [Answers logCustomEventWithName:[NSString stringWithFormat: @"Article Shared: %@", url] // not good
                        customAttributes:@{}];
}

// Swift
func logArticleShared(url: String) {
    Answers.logCustomEventWithName("Article Shared: " + url,  // not good
                        customAttributes: nil)
}

Logging events like this will allow you to see your most shared articles, but to see them you’ll have to sift through all your other top events such as purchases and sign ups. Instead, you should set your event type to a constant, and use attributes to capture your variable values:

// Objective-C
- (void) logArticleShared:(NSString *)url {
    [Answers logCustomEventWithName:@"Article Shared"
                        customAttributes:@{
                            @"Article URL" : url}]; // great! - make it an attribute instead
}

// Swift
func logArticleShared(url: String) {
    Answers.logCustomEventWithName("Article Shared",
                        customAttributes: [
                            "Article URL": url]) // great! - make it an attribute instead
}

Besides making viewing your top articles easier, using attributes like this will allow you to see metrics about all of your app’s events aggregated together, such as the percentage of users per day that shared any article. You can then view metrics about your app’s events in context, like the percentage of your total shares that came from each of the top articles. You can also add multiple attributes to the same event to get even more metrics about the same events, all in one place.