AMPRevenue Class Reference

Inherits from NSObject
Declared in AMPRevenue.h
AMPRevenue.m

Overview

AMPRevenue objects are a wrapper for revenue data, which get passed to the logRevenueV2 method to send to Amplitude servers.

Note: price is a required field. If quantity is not specified, then defaults to 1.

Note: Revenue amount is calculated as price * quantity.

Each method updates a revenue property in the Revenue object, and returns the same Revenue object, allowing you to chain multiple method calls together.

Here is an example of how to use AMPRevenue to send revenue data:

AMPRevenue *revenue = [[[AMPRevenue revenue] setProductIdentifier:@"productIdentifier"] setQuantity:3];
[revenue setPrice:[NSNumber numberWithDouble:3.99]];
[[Amplitude instance] logRevenueV2:revenue];

See Tracking Revenue for more information about logging Revenue.

Other Methods

+ revenue

Creates a new AMPRevenue object.

+ (instancetype)revenue

Return Value

a new AMPRevenue object.

Discussion

Creates a new AMPRevenue object.

Declared In

AMPRevenue.h

– setProductIdentifier:

Set a value for the product identifier.

- (AMPRevenue *)setProductIdentifier:(NSString *)productIdentifier

Parameters

productIdentifier

The value for the product identifier. Empty strings are ignored.

Return Value

the same AMPRevenue object, allowing you to chain multiple method calls together.

Discussion

Set a value for the product identifier.

Declared In

AMPRevenue.h

– setQuantity:

Set a value for the quantity.

- (AMPRevenue *)setQuantity:(NSInteger)quantity

Parameters

quantity

Integer value for the quantity. Defaults to 1 if not specified.

Return Value

the same AMPRevenue object, allowing you to chain multiple method calls together.

Discussion

Set a value for the quantity.

Note revenue amount is calculated as price * quantity.

Declared In

AMPRevenue.h

– setPrice:

Set a value for the price.

- (AMPRevenue *)setPrice:(NSNumber *)price

Parameters

price

The value for the price.

Return Value

the same AMPRevenue object, allowing you to chain multiple method calls together.

Discussion

Set a value for the price.

Note revenue amount is calculated as price * quantity.

Declared In

AMPRevenue.h

– setRevenueType:

Set a value for the revenueType (for example purchase, cost, tax, refund, etc).

- (AMPRevenue *)setRevenueType:(NSString *)revenueType

Parameters

revenueType

String value for the revenue type.

Return Value

the same AMPRevenue object, allowing you to chain multiple method calls together.

Discussion

Set a value for the revenueType (for example purchase, cost, tax, refund, etc).

Declared In

AMPRevenue.h

– setReceipt:

Add the receipt data for the transaction. Reequired if you want to verify this revenue event.

- (AMPRevenue *)setReceipt:(NSData *)receipt

Parameters

receipt

The receipt data from the App Store.

Return Value

the same AMPRevenue object, allowing you to chain multiple method calls together.

Discussion

Add the receipt data for the transaction. Reequired if you want to verify this revenue event.

Declared In

AMPRevenue.h

– setEventProperties:

Set event properties for the revenue event.

- (AMPRevenue *)setEventProperties:(NSDictionary *)eventProperties

Parameters

eventProperties

An NSDictionary of event properties to set for the revenue event.

Return Value

the same AMPRevenue object, allowing you to chain multiple method calls together.

Discussion

Set event properties for the revenue event.

Declared In

AMPRevenue.h

Required Revenue Fields

  productId

The product identifier for the transaction (optional).

@property (nonatomic, strong, readonly) NSString *productId

Discussion

The product identifier for the transaction (optional).

Declared In

AMPRevenue.h

  price

The price of product(s) in the transaction.

@property (nonatomic, strong, readonly) NSNumber *price

Discussion

The price of product(s) in the transaction.

@warning: required field

Declared In

AMPRevenue.h

Optional Revenue Fields

  quantity

The quantity of product(s) purchased in the transaction.

@property (nonatomic, readonly) NSInteger quantity

Discussion

The quantity of product(s) purchased in the transaction.

@warning: defaults to 1

Declared In

AMPRevenue.h

  revenueType

The revenue type for the transaction (optional).

@property (nonatomic, strong, readonly) NSString *revenueType

Discussion

The revenue type for the transaction (optional).

Declared In

AMPRevenue.h

  receipt

The receipt data for the transaction. Required if you want to verify the revenue event.

@property (nonatomic, strong, readonly) NSData *receipt

Discussion

The receipt data for the transaction. Required if you want to verify the revenue event.

Declared In

AMPRevenue.h

  properties

Event properties for the revenue event.

@property (nonatomic, strong, readonly) NSDictionary *properties

Discussion

Event properties for the revenue event.

Declared In

AMPRevenue.h