KongAnalytics Class Reference

Inherits from NSObject
Declared in KongAnalytics.h

Overview

This interface wraps the functionality provided by the Adjust and Swrve SDKs. It also includeds legacy support for Keen. Ad-X has been removed from the Kongregate SDK.

The primary purpose of this interface is to expose hooks for games to pass events to Swrve and Adjust. It also provides wrappers for some additional Swrve features such as User Properties, A/B Testing, and Push Notifications. See the Mobile SDK Docs for details of the various features.

– addEvent:toCollection:

Submits an event with the given collection name to Keen and Swrve.

- (void)addEvent:(NSDictionary *)event toCollection:(NSString *)eventCollection

Parameters

event

The event properties (key/value pairs)

eventCollection

The name of the event/collection to submit

Declared In

KongAnalytics.h

– addEvent:withEventJson:withCommonPropsJson:

Helper method similar to addEvent:toCollection which only takes NSString arguments. This is helpful for writing plugins in languages which can’t easily create an NSDictionary.

- (void)addEvent:(NSString *)collection withEventJson:(NSString *)eventJson withCommonPropsJson:(NSString *)commonPropsJson

Parameters

collection

The collection name

eventJson

A valid JSON object string with the event properties

commonPropsJson

A valid JSON object string containing common properties.

Declared In

KongAnalytics.h

– setCommonPropertiesBlock:

Sets the common properties callback as a block which returns an NSDictionary. This block will be called each time an event is submitted to populate the common fields for that event.

- (void)setCommonPropertiesBlock:(NSDictionary *( ^ ) ( void ))block

Parameters

block

A block that returns an NSDictionary of properties

Declared In

KongAnalytics.h

– setAutoEventListener:

Sets a listener for analytic events the Kongregate SDK automatically fires. Most games will not need to listen for these events. It’s useful if you wish to echo the events to your own analytics collection system.

- (void)setAutoEventListener:(void ( ^ ) ( NSString *, NSDictionary *))block

Parameters

block

A block to be notified when auto events are fired

Declared In

KongAnalytics.h

– setCommonPropertiesJSON:

Sets the common properties to the given JSON string. Useful for native bindings to other languages where the callback method can’t be used.

- (void)setCommonPropertiesJSON:(NSString *)json

Parameters

json

A valid JSON object string with the common properties.

Declared In

KongAnalytics.h

– setCommonProperties:

Sets the common properties to the given NSDictionary. Useful for native bindings to other languages where the callback method can’t be used.

- (void)setCommonProperties:(NSDictionary *)commonProps

Parameters

commonProps

A valid JSON object string with the common properties.

Declared In

KongAnalytics.h

– trackPurchase:

see finishPurchase (Deprecated: see finishPurchase)

- (void)trackPurchase:(NSString *)productID

Parameters

productID

the product ID

Declared In

KongAnalytics.h

– trackPurchase:withQuantity:

see finishPurchase (Deprecated: see finishPurchase)

- (void)trackPurchase:(NSString *)productID withQuantity:(int)quantity

Parameters

productID

The product ID

quantity

The quantity of items purchased

Declared In

KongAnalytics.h

– trackPurchase:withQuantity:withGameFieldsJson:

see finishPurchase (Deprecated: see finishPurchase)

- (void)trackPurchase:(NSString *)productID withQuantity:(int)quantity withGameFieldsJson:(NSString *)jsonFields

Parameters

productID

The product ID

quantity

The quantity of items purchased

jsonFields

An optional JSON object string with custom event fields for the Keen event

Declared In

KongAnalytics.h

– trackPurchase:withQuantity:withGameFields:

see finishPurchase (Deprecated: see finishPurchase)

- (void)trackPurchase:(NSString *)productID withQuantity:(int)quantity withGameFields:(NSDictionary *)fields

Parameters

productID

The product ID

quantity

The quantity of items purchased

fields

An optional dictionary containing custom event fields to pass along

Declared In

KongAnalytics.h

– startPurchase:withQuantity:withGameFields:

Creates an iap_attemps event. The SKU must match the one set up in the iTunes Connect portal, and must contain the pricing tier, such as: t05_hard

- (void)startPurchase:(NSString *)productID withQuantity:(int)quantity withGameFields:(NSDictionary *)fields

Parameters

productID

The product ID

quantity

The quantity of items purchased

fields

An optional dictionary containing custom event fields to pass along

Declared In

KongAnalytics.h

– finishPurchase:withTransactionId:withGameFields:

Creates either iap_transactions or iap_fails purchase events depending on arguments and state of the transaction. Invoke this method after the transcation completed, but before it is finished.

- (void)finishPurchase:(NSString *)resultCode withTransactionId:(NSString *)transactionId withGameFields:(NSDictionary *)gameFields

Parameters

resultCode

one of KONG_PURCHASE_SUCCESS, KONG_PURCHASE_FAIL, KONG_PURCAHSE_RECEIPT_FAIL

transactionId

the SKUPurchase.transactionIdentifier

gameFields

game fields to be passed along with the event

Discussion

The resultCode parameter should be one of: KONG_PURCHASE_SUCCESS: if the transaction was successfully completed KONG_PURCHASE_FAIL: if the transaction failed KONG_PURCHASE_RECEIPT_FAIL: if the transaction was successfull, but reciept verification failed.

Declared In

KongAnalytics.h

– finishPurchase:withTransactionId:withGameFieldsJson:

Creates either iap_transactions or iap_fails purchase events depending on arguments and state of the transaction. Invoke this method after the transcation completed, but before it is finished.

- (void)finishPurchase:(NSString *)resultCode withTransactionId:(NSString *)transactionId withGameFieldsJson:(NSString *)gameFieldsJson

Parameters

resultCode

one of KONG_PURCHASE_SUCCESS, KONG_PURCHASE_FAIL, KONG_PURCAHSE_RECEIPT_FAIL

transactionId

the SKUPurchase.transactionIdentifier

gameFieldsJson

game fields to be passed along with the event

Discussion

The resultCode parameter should be one of: KONG_PURCHASE_SUCCESS: if the transaction was successfully completed KONG_PURCHASE_FAIL: if the transaction failed KONG_PURCHASE_RECEIPT_FAIL: if the transaction was successfull, but reciept verification failed.

Declared In

KongAnalytics.h

– finishPurchase:withProductId:withReceipt:withGameFields:

Creates either iap_transactions or iap_fails purchase events depending on the result code. If transaction ID is available, use the finishPurchase:withTransactionId varients, since they will automatically pull information from the transaction queue. This method is provided for compatibility with plugins or APIs that don’t provide access to the transaction ID.

- (void)finishPurchase:(NSString *)resultCode withProductId:(NSString *)productId withReceipt:(NSString *)receipt withGameFields:(NSDictionary *)gameFields

Parameters

resultCode

one of KONG_PURCHASE_SUCCESS, KONG_PURCHASE_FAIL, KONG_PURCAHSE_RECEIPT_FAIL

productId

the SKUPurchase.transactionIdentifier

receipt

a Base64 encoded receipt

gameFields

game fields to be passed along with the event

Discussion

The resultCode parameter should be one of: KONG_PURCHASE_SUCCESS: if the transaction was successfully completed KONG_PURCHASE_FAIL: if the transaction failed KONG_PURCHASE_RECEIPT_FAIL: if the transaction was successfull, but reciept verification failed.

Declared In

KongAnalytics.h

– finishPurchase:withProductId:withReceipt:withGameFieldsJson:

Creates either iap_transactions or iap_fails purchase events depending on the result code. If transaction ID is available, use the finishPurchase:withTransactionId varients, since they will automatically pull information from the transaction queue. This method is provided for compatibility with plugins or APIs that don’t provide access to the transaction ID.

- (void)finishPurchase:(NSString *)resultCode withProductId:(NSString *)productId withReceipt:(NSString *)receipt withGameFieldsJson:(NSString *)gameFieldsJson

Parameters

resultCode

one of KONG_PURCHASE_SUCCESS, KONG_PURCHASE_FAIL, KONG_PURCAHSE_RECEIPT_FAIL

productId

the SKUPurchase.transactionIdentifier

receipt

a Base64 encoded receipt

gameFieldsJson

game fields to be passed along with the event

Discussion

The resultCode parameter should be one of: KONG_PURCHASE_SUCCESS: if the transaction was successfully completed KONG_PURCHASE_FAIL: if the transaction failed KONG_PURCHASE_RECEIPT_FAIL: if the transaction was successfull, but receipt verification failed.

Declared In

KongAnalytics.h

– addIapTransaction:withTransactionId:withGameFields:

Add a Kongregate Analytics iap_transaction event and Adjust sale event for an iOS Purchase.

- (void)addIapTransaction:(double)revenue withTransactionId:(NSString *)transactionId withGameFields:(NSDictionary *)gameFields

Parameters

revenue

the purchase price of the item in US Dollars

transactionId

the iOS transaction ID for the purchase

gameFields

Dictionary of additional fields to include with the event (e.g. soft_currency_change)

Discussion

This is the preferred method to use when the purchased product does not conform to the TXX_description naming convention. It is preferred because the revenue is explicitly provided in USD where we are unable to infer the USD cost from the ID. By including the iOS transaction ID we can extract additional information about the purchase.

This should be invoked after the purchase is complete and the receipt verified but before the transaction is consumed. Once a transaction is consumed the SDK can no longer extract information from the payment queue.

Declared In

KongAnalytics.h

– addIapTransaction:withTransactionId:withGameFieldsJSON:

Add a Kongregate Analytics iap_transaction event and Adjust sale event for an iOS Purchase.

- (void)addIapTransaction:(double)revenue withTransactionId:(NSString *)transactionId withGameFieldsJSON:(NSString *)gameFieldsJson

Parameters

revenue

the purchase price of the item in US Dollars

transactionId

the iOS transaction ID for the purchase

gameFieldsJson

JSON formated object of additional fields to include with the event (e.g. soft_currency_change)

Discussion

This is the preferred method to use when the purchased product does not conform to the TXX_description naming convention. It is preferred because the revenue is explicitly provided in USD where we are unable to infer the USD cost from the ID. By including the iOS transaction ID we can extract additional information about the purchase.

This should be invoked after the purchase is complete and the receipt verified but before the transaction is consumed. Once a transaction is consumed the SDK can no longer extract information from the payment queue.

Declared In

KongAnalytics.h

– addIapTransaction:withCurrency:withTransactionId:withGameFields:

Add a Kongregate Analytics iap_transaction event and Adjust sale event for an iOS Purchase.

- (void)addIapTransaction:(double)revenue withCurrency:(NSString *)currencyType withTransactionId:(NSString *)transactionId withGameFields:(NSDictionary *)gameFields

Parameters

revenue

the purchase price of the item in the given currency

currencyType

the currency code the revenue is reported in.

transactionId

the iOS transaction ID for the purchase

gameFields

Dictionary of additional fields to include with the event (e.g. soft_currency_change )

Discussion

addIapTransaction:withTransactionId:withGameFields:` is the preferred method to use since it allows revenue to be normalized to USD. However, this method may be used when the USD price is unknown. Adjust does convert the revenue to USD, however Kongregate Analytics will not.

This should be invoked after the purchase is complete and the receipt verified but before the transaction is consumed. Once a transaction is consumed the SDK can no longer extract information from the payment queue.

Declared In

KongAnalytics.h

– addIapTransaction:withCurrency:withTransactionId:withGameFieldsJSON:

Add a Kongregate Analytics iap_transaction event and Adjust sale event for an iOS Purchase.

- (void)addIapTransaction:(double)revenue withCurrency:(NSString *)currencyType withTransactionId:(NSString *)transactionId withGameFieldsJSON:(NSString *)gameFieldsJson

Parameters

revenue

the purchase price of the item in the given currency

currencyType

the currency code the revenue is reported in.

transactionId

the iOS transaction ID for the purchase

gameFieldsJson

JSON formated object of additional fields to include with the event (e.g. soft_currency_change)

Discussion

addIapTransaction:withTransactionId:withGameFields:` is the preferred method to use since it allows revenue to be normalized to USD. However, this method may be used when the USD price is unknown. Adjust does convert the revenue to USD, however Kongregate Analytics will not.

This should be invoked after the purchase is complete and the receipt verified but before the transaction is consumed. Once a transaction is consumed the SDK can no longer extract information from the payment queue.

Declared In

KongAnalytics.h

– addIapTransaction:withCurrency:withProductId:withGameFields:

Add a Kongregate Analytics iap_transaction event and Adjust sale event for an iOS or Google Purchase.

- (void)addIapTransaction:(double)revenue withCurrency:(NSString *)currencyType withProductId:(NSString *)productId withGameFields:(NSDictionary *)gameFields

Parameters

revenue

the purchase price of the item in the given currency

currencyType

the currency code the revenue is reported in.

productId

the identifier for the purchased product

gameFields

Dictionary of additional fields to include with the event (e.g. soft_currency_change)

Discussion

addIapTransaction:withTransactionId:withGameFields: is the preferred methods addIapTransaction:withCurrency:withProductId:withGameFields: may be used when the iOS transaction is not available.

Declared In

KongAnalytics.h

– addIapTransaction:withCurrency:withProductId:withGameFieldsJSON:

Add a Kongregate Analytics iap_transaction event and Adjust sale event for an iOS or Google Purchase.

- (void)addIapTransaction:(double)revenue withCurrency:(NSString *)currnecyType withProductId:(NSString *)productId withGameFieldsJSON:(NSString *)gameFieldsJson

Parameters

revenue

the purchase price of the item in the given currency

currnecyType

the currency code the revenue is reported in.

productId

the identifier for the purchased product

gameFieldsJson

JSON formated object of additional fields to include with the event (e.g. soft_currency_change)

Discussion

addIapTransaction:withTransactionId:withGameFields: is the preferred methods addIapTransaction:withCurrency:withProductId:withGameFields: may be used when the iOS transaction is not available.

Declared In

KongAnalytics.h

– startPurchase:withQuantity:withGameFieldsJson:

Creates a start purchase event. The SKU must match the one set up in the iTunes Connect portal, and must contain the pricing tier, such as: t05_hard

- (void)startPurchase:(NSString *)productID withQuantity:(int)quantity withGameFieldsJson:(NSString *)jsonFields

Parameters

productID

The product ID

quantity

The quantity of items purchased

jsonFields

An optional JSON object string with custom event fields for the Keen event

Declared In

KongAnalytics.h

– gameUserUpdate:

Update game specific user properties with Swrve. The Kongregaet SDK automatically updates a set of user properties with Swrve as well. This method is to be used for game specific user segmentation.

- (void)gameUserUpdate:(NSDictionary *)props

Parameters

props

Dictionary of user state attributes.

Declared In

KongAnalytics.h

– gameUserUpdateJSON:

Update game specific user properties with Swrve. The Kongregaet SDK automatically updates a set of user properties with Swrve as well. This method is to be used for game specific user segmentation.

- (void)gameUserUpdateJSON:(NSString *)propsJson

Parameters

propsJson

A JSON formatted string object of user state attributes

Declared In

KongAnalytics.h

– isDeltaEnabled

Get a boolean of whether DeltaDNA is remotely enabled or disabled

- (BOOL)isDeltaEnabled

Return Value

a boolean of whether DeltaDNA is remotely enabled

Declared In

KongAnalytics.h

– getAutoPropertiesJSON

Retrieve the complete set of automatic properties Kongregate tracks as a JSON formatted string.

- (NSString *)getAutoPropertiesJSON

Declared In

KongAnalytics.h

– getAutoStringProperty:

Get a String automatic property

- (NSString *)getAutoStringProperty:(NSString *)field

Parameters

field

The field name

Return Value

The prop value

Declared In

KongAnalytics.h

– getAutoLongLongProperty:

Get a 64-bit integer automatic property

- (int64_t)getAutoLongLongProperty:(NSString *)field

Parameters

field

The field name

Return Value

The prop value

Declared In

KongAnalytics.h

– getAutoBoolProperty:

Get a boolean automatic property

- (BOOL)getAutoBoolProperty:(NSString *)field

Parameters

field

The field name

Return Value

The prop value

Declared In

KongAnalytics.h

– getAutoIntProperty:

Get an integer automatic property

- (int)getAutoIntProperty:(NSString *)field

Parameters

field

The field name

Return Value

The prop value

Declared In

KongAnalytics.h

– getAutoUTCProperty:

Get a UTC timestamp automatic property

- (NSString *)getAutoUTCProperty:(NSString *)field

Parameters

field

The field name

Return Value

The prop value

Declared In

KongAnalytics.h

– getAutoDoubleProperty:

Get a double automatic property

- (double)getAutoDoubleProperty:(NSString *)field

Parameters

field

The field name

Return Value

The prop value

Declared In

KongAnalytics.h

– setFilterType:

use addFilterType instead Set a custom filter type to be sent with every event (Deprecated: use addFilterType instead Set a custom filter type to be sent with every event)

- (void)setFilterType:(NSString *)filterType

Parameters

filterType

the prop value

Declared In

KongAnalytics.h

– addFilterType:

Adds a custom filter type to be sent with every event

- (void)addFilterType:(NSString *)filterType

Parameters

filterType

the prop value

Declared In

KongAnalytics.h

– setPushToken:

Notifies adjust the device token for iOS. When set and configured on the Adjust dashboard, Adjust will track uninstall and re-install events.

- (void)setPushToken:(NSData *)pushToken

Parameters

pushToken

The Firebase push token for Android or the base64 encoded device token for iOS

Declared In

KongAnalytics.h

– start

When using KONGREGATE_OPTION_DEFER_ANALYTICS, this allows you to start the analytics subsystem. You should attempt to call this function as quickly as possible after starting up, or you may miss events.

- (void)start

Declared In

KongAnalytics.h

– getResources

Get all Swrve resources. @retruns a dictionary of resource names to SwrveResource objects

- (NSDictionary *)getResources

Declared In

KongAnalytics.h

– getResourceNames

Get all Swrve resource names

- (NSArray *)getResourceNames

Return Value

an array of NSString resource names.

Declared In

KongAnalytics.h

– getResourceNamesAsJson

Get all Swrve resource names as a JSON Array

- (NSString *)getResourceNamesAsJson

Return Value

a JSON Array formatted NSString of all Swrve resource names.

Declared In

KongAnalytics.h

– getResourceAsInt:withAttr:withDefault:

Retrieve a Swrve A/B test resource as an int.

- (int)getResourceAsInt:(NSString *)resourceId withAttr:(NSString *)attrId withDefault:(int)defValue

Parameters

resourceId

the ID of the Swrve resource

attrId

the ID of the attribute

defValue

a devault value if the resource/attribute is not found.

Return Value

the value of the attribute in the resource, or the default alue if not found.

Declared In

KongAnalytics.h

– getResourceAsFloat:withAttr:withDefault:

Retrieve a Swrve A/B test resource as a float.

- (float)getResourceAsFloat:(NSString *)resourceId withAttr:(NSString *)attrId withDefault:(float)defValue

Parameters

resourceId

the ID of the Swrve resource

attrId

the ID of the attribute

defValue

a devault value if the resource/attribute is not found.

Return Value

the value of the attribute in the resource, or the default alue if not found.

Declared In

KongAnalytics.h

– getResourceAsBool:withAttr:withDefault:

Retrieve a Swrve A/B test resource as a boolean.

- (BOOL)getResourceAsBool:(NSString *)resourceId withAttr:(NSString *)attrId withDefault:(BOOL)defValue

Parameters

resourceId

the ID of the Swrve resource

attrId

the ID of the attribute

defValue

a devault value if the resource/attribute is not found.

Return Value

the value of the attribute in the resource, or the default alue if not found.

Declared In

KongAnalytics.h

– setSwrveButtonCallback:

Sets the callback listener for Delta in-app messages [Deprecated] Will be invoked when a deep link is selected as the message Action.

- (void)setSwrveButtonCallback:(void ( ^ ) ( NSString *, NSString *))callback

Parameters

callback

to be invoked

Declared In

KongAnalytics.h

– setDeltaButtonCallback:

Sets the callback listener for Delta in-app messages Will be invoked when a deep link is selected as the message Action.

- (void)setDeltaButtonCallback:(void ( ^ ) ( NSString *, NSString *))callback

Parameters

callback

to be invoked

Declared In

KongAnalytics.h

– setDeltaParameterCallback:

Sets the callback listener for Delta parameters Will be invoked when parameters are returned in response to an event

- (void)setDeltaParameterCallback:(void ( ^ ) ( NSDictionary *))callback

Parameters

callback

to be invoked

Declared In

KongAnalytics.h

– finishPromoAward:

Notify the Kongregate SDK that a promo award has been handled. This will update a Swrve User Property that may be used as a filter for additional Swrve messaging.

- (void)finishPromoAward:(NSString *)eventPayload

Parameters

eventPayload

the event payload for the PROMO_AWARD event.

Discussion

It’s a good idea, particularly if your game has a server component, to also track awarded promoIds and to display a message if your game is asked to award a promo that has already been awarded. This will handle an edge case where a user can trick the client into showing an in-app message to perform the award again.

NOTE: you may also simply pass the promoID for the event, rather than the complete payload. When only the promoID is passed, the user property will be updated. When the full event payload is included, the SDK will parse the payload and may automatically preform other actions such as open an install URL.

Declared In

KongAnalytics.h

– getKongregatePropertiesJSON

Returns the common analytics properties collected by the Kongregate SDK

- (NSString *)getKongregatePropertiesJSON

Declared In

KongAnalytics.h

– getTransactionDetailsJSON:withResult:

Returns a json string of the Apple transaction details for the given transaction

- (NSString *)getTransactionDetailsJSON:(NSString *)transactionId withResult:(NSString *)resultCode

Parameters

transactionId

The transaction identifier; if null or empty, attempts to retrieve last transaction details from queue

resultCode

The result of transaction

Declared In

KongAnalytics.h