Answers

@interface Answers : NSObject

This class exposes the Answers Events API, allowing you to track key user user actions and metrics in your app.

  • Log a Sign Up event 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.

    Declaration

    Swift

    class func logSignUp(withMethod signUpMethodOrNil: String?, success signUpSucceededOrNil: NSNumber?, customAttributes customAttributesOrNil: [AnyHashable : Any]? = nil)

    Objective-C

    + (void)logSignUpWithMethod:(nullable NSString *)signUpMethodOrNil
                        success:(nullable NSNumber *)signUpSucceededOrNil
               customAttributes:(nullable NSDictionary *)customAttributesOrNil;

    Parameters

    signUpMethodOrNil

    The method by which a user logged in, e.g. Twitter or Digits.

    signUpSucceededOrNil

    The ultimate success or failure of the login

    customAttributesOrNil

    A dictionary of custom attributes to associate with this event.

  • Log an Log In event 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.

    Declaration

    Swift

    class func logLogin(withMethod loginMethodOrNil: String?, success loginSucceededOrNil: NSNumber?, customAttributes customAttributesOrNil: [AnyHashable : Any]? = nil)

    Objective-C

    + (void)logLoginWithMethod:(nullable NSString *)loginMethodOrNil
                       success:(nullable NSNumber *)loginSucceededOrNil
              customAttributes:(nullable NSDictionary *)customAttributesOrNil;

    Parameters

    loginMethodOrNil

    The method by which a user logged in, e.g. email, Twitter or Digits.

    loginSucceededOrNil

    The ultimate success or failure of the login

    customAttributesOrNil

    A dictionary of custom attributes to associate with this event.

  • Log a Share event 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.

    Declaration

    Swift

    class func logShare(withMethod shareMethodOrNil: String?, contentName contentNameOrNil: String?, contentType contentTypeOrNil: String?, contentId contentIdOrNil: String?, customAttributes customAttributesOrNil: [AnyHashable : Any]? = nil)

    Objective-C

    + (void)logShareWithMethod:(nullable NSString *)shareMethodOrNil
                   contentName:(nullable NSString *)contentNameOrNil
                   contentType:(nullable NSString *)contentTypeOrNil
                     contentId:(nullable NSString *)contentIdOrNil
              customAttributes:(nullable NSDictionary *)customAttributesOrNil;

    Parameters

    shareMethodOrNil

    The method by which a user shared, e.g. email, Twitter, SMS.

    contentNameOrNil

    The human readable name for this piece of content.

    contentTypeOrNil

    The type of content shared.

    contentIdOrNil

    The unique identifier for this piece of content. Useful for finding the top shared item.

    customAttributesOrNil

    A dictionary of custom attributes to associate with this event.

  • Log an Invite Event to track how users are inviting other users into your application.

    Declaration

    Swift

    class func logInvite(withMethod inviteMethodOrNil: String?, customAttributes customAttributesOrNil: [AnyHashable : Any]? = nil)

    Objective-C

    + (void)logInviteWithMethod:(nullable NSString *)inviteMethodOrNil
               customAttributes:(nullable NSDictionary *)customAttributesOrNil;

    Parameters

    inviteMethodOrNil

    The method of invitation, e.g. GameCenter, Twitter, email.

    customAttributesOrNil

    A dictionary of custom attributes to associate with this event.

  • Log a Purchase event 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.

    Declaration

    Swift

    class func logPurchase(withPrice itemPriceOrNil: NSDecimalNumber?, currency currencyOrNil: String?, success purchaseSucceededOrNil: NSNumber?, itemName itemNameOrNil: String?, itemType itemTypeOrNil: String?, itemId itemIdOrNil: String?, customAttributes customAttributesOrNil: [AnyHashable : Any]? = nil)

    Objective-C

    + (void)logPurchaseWithPrice:(nullable NSDecimalNumber *)itemPriceOrNil
                        currency:(nullable NSString *)currencyOrNil
                         success:(nullable NSNumber *)purchaseSucceededOrNil
                        itemName:(nullable NSString *)itemNameOrNil
                        itemType:(nullable NSString *)itemTypeOrNil
                          itemId:(nullable NSString *)itemIdOrNil
                customAttributes:(nullable NSDictionary *)customAttributesOrNil;

    Parameters

    itemPriceOrNil

    The purchased item’s price.

    currencyOrNil

    The ISO4217 currency code. Example: USD

    purchaseSucceededOrNil

    Was the purchase successful or unsuccessful

    itemNameOrNil

    The human-readable form of the item’s name. Example:

    itemTypeOrNil

    The type, or genre of the item. Example: Song

    itemIdOrNil

    The machine-readable, unique item identifier Example: SKU

    customAttributesOrNil

    A dictionary of custom attributes to associate with this purchase.

  • Log a Level Start Event to track where users are in your game.

    Declaration

    Swift

    class func logLevelStart(_ levelNameOrNil: String?, customAttributes customAttributesOrNil: [AnyHashable : Any]? = nil)

    Objective-C

    + (void)logLevelStart:(nullable NSString *)levelNameOrNil
         customAttributes:(nullable NSDictionary *)customAttributesOrNil;

    Parameters

    levelNameOrNil

    The level name

    customAttributesOrNil

    A dictionary of custom attributes to associate with this level start event.

  • Log a Level End event to track how users are completing levels in your game.

    Declaration

    Swift

    class func logLevelEnd(_ levelNameOrNil: String?, score scoreOrNil: NSNumber?, success levelCompletedSuccesfullyOrNil: NSNumber?, customAttributes customAttributesOrNil: [AnyHashable : Any]? = nil)

    Objective-C

    + (void)logLevelEnd:(nullable NSString *)levelNameOrNil
                   score:(nullable NSNumber *)scoreOrNil
                 success:(nullable NSNumber *)levelCompletedSuccesfullyOrNil
        customAttributes:(nullable NSDictionary *)customAttributesOrNil;

    Parameters

    levelNameOrNil

    The name of the level completed, E.G. 1 or Training

    scoreOrNil

    The score the user completed the level with.

    levelCompletedSuccesfullyOrNil

    A boolean representing whether or not the level was completed successfully.

    customAttributesOrNil

    A dictionary of custom attributes to associate with this event.

  • Log an Add to Cart event 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.

    Declaration

    Swift

    class func logAddToCart(withPrice itemPriceOrNil: NSDecimalNumber?, currency currencyOrNil: String?, itemName itemNameOrNil: String?, itemType itemTypeOrNil: String?, itemId itemIdOrNil: String?, customAttributes customAttributesOrNil: [AnyHashable : Any]? = nil)

    Objective-C

    + (void)logAddToCartWithPrice:(nullable NSDecimalNumber *)itemPriceOrNil
                         currency:(nullable NSString *)currencyOrNil
                         itemName:(nullable NSString *)itemNameOrNil
                         itemType:(nullable NSString *)itemTypeOrNil
                           itemId:(nullable NSString *)itemIdOrNil
                 customAttributes:(nullable NSDictionary *)customAttributesOrNil;

    Parameters

    itemPriceOrNil

    The purchased item’s price.

    currencyOrNil

    The ISO4217 currency code. Example: USD

    itemNameOrNil

    The human-readable form of the item’s name. Example:

    itemTypeOrNil

    The type, or genre of the item. Example: Song

    itemIdOrNil

    The machine-readable, unique item identifier Example: SKU

    customAttributesOrNil

    A dictionary of custom attributes to associate with this event.

  • Log a Start Checkout event 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.

    Declaration

    Swift

    class func logStartCheckout(withPrice totalPriceOrNil: NSDecimalNumber?, currency currencyOrNil: String?, itemCount itemCountOrNil: NSNumber?, customAttributes customAttributesOrNil: [AnyHashable : Any]? = nil)

    Objective-C

    + (void)logStartCheckoutWithPrice:(nullable NSDecimalNumber *)totalPriceOrNil
                             currency:(nullable NSString *)currencyOrNil
                            itemCount:(nullable NSNumber *)itemCountOrNil
                     customAttributes:
                         (nullable NSDictionary *)customAttributesOrNil;

    Parameters

    totalPriceOrNil

    The total price of the cart.

    currencyOrNil

    The ISO4217 currency code. Example: USD

    itemCountOrNil

    The number of items in the cart.

    customAttributesOrNil

    A dictionary of custom attributes to associate with this event.

  • Log a Rating event 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.

    Declaration

    Swift

    class func logRating(_ ratingOrNil: NSNumber?, contentName contentNameOrNil: String?, contentType contentTypeOrNil: String?, contentId contentIdOrNil: String?, customAttributes customAttributesOrNil: [AnyHashable : Any]? = nil)

    Objective-C

    + (void)logRating:(nullable NSNumber *)ratingOrNil
             contentName:(nullable NSString *)contentNameOrNil
             contentType:(nullable NSString *)contentTypeOrNil
               contentId:(nullable NSString *)contentIdOrNil
        customAttributes:(nullable NSDictionary *)customAttributesOrNil;

    Parameters

    ratingOrNil

    The integer rating given by the user.

    contentNameOrNil

    The human readable name for this piece of content.

    contentTypeOrNil

    The type of content shared.

    contentIdOrNil

    The unique identifier for this piece of content. Useful for finding the top shared item.

    customAttributesOrNil

    A dictionary of custom attributes to associate with this event.

  • Log a Content View event 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.

    Declaration

    Swift

    class func logContentView(withName contentNameOrNil: String?, contentType contentTypeOrNil: String?, contentId contentIdOrNil: String?, customAttributes customAttributesOrNil: [AnyHashable : Any]? = nil)

    Objective-C

    + (void)logContentViewWithName:(nullable NSString *)contentNameOrNil
                       contentType:(nullable NSString *)contentTypeOrNil
                         contentId:(nullable NSString *)contentIdOrNil
                  customAttributes:(nullable NSDictionary *)customAttributesOrNil;

    Parameters

    contentNameOrNil

    The human readable name for this piece of content.

    contentTypeOrNil

    The type of content shared.

    contentIdOrNil

    The unique identifier for this piece of content. Useful for finding the top shared item.

    customAttributesOrNil

    A dictionary of custom attributes to associate with this event.

  • Log a Search event allows you to see users searching within your app in real-time and understand exactly what they’re searching for.

    Declaration

    Swift

    class func logSearch(withQuery queryOrNil: String?, customAttributes customAttributesOrNil: [AnyHashable : Any]? = nil)

    Objective-C

    + (void)logSearchWithQuery:(nullable NSString *)queryOrNil
              customAttributes:(nullable NSDictionary *)customAttributesOrNil;

    Parameters

    queryOrNil

    The user’s query.

    customAttributesOrNil

    A dictionary of custom attributes to associate with this event.

  • Log a Custom Event to see user actions that are uniquely important for your app in real-time, to see how often they’re performing these actions with breakdowns by different categories you add. Use a human-readable name for the name of the event, since this is how the event will appear in Answers.

    Declaration

    Swift

    class func logCustomEvent(withName eventName: String, customAttributes customAttributesOrNil: [AnyHashable : Any]? = nil)

    Objective-C

    + (void)logCustomEventWithName:(nonnull NSString *)eventName
                  customAttributes:(nullable NSDictionary *)customAttributesOrNil;

    Parameters

    eventName

    The human-readable name for the event.

    customAttributesOrNil

    A dictionary of custom attributes to associate with this event. Attribute keys must be NSString and values must be NSNumber or NSString. @discussion How we treat NSNumbers: We will provide information about the distribution of values over time.

                           How we treat NSStrings:
                           NSStrings are used as categorical data, allowing comparison across different category values.
                           Strings are limited to a maximum length of 100 characters, attributes over this length will be
                           truncated.
    
                           When tracking the Tweet views to better understand user engagement, sending the tweet's length
                           and the type of media present in the tweet allows you to track how tweet length and the type of media influence
                           engagement.