我想使用适用于 iOS v2 的 Google Analytics SDK 跟踪应用内购买,如他们的电子商务跟踪指南中所述。
SKPaymentTransactionStatePurchased
收到交易更新后,我目前正在执行以下操作:
- (void) trackTransaction:(SKPaymentTransaction*)transaction
{
NSString *transactionIdentifier = transaction.transactionIdentifier;
GAITransaction *gaiTransaction = [GAITransaction transactionWithId:transactionIdentifier withAffiliation:@"App Store"];
SKPayment *payment = transaction.payment;
NSString *productIdentifier = payment.productIdentifier;
SKProduct *product = [self productForIdentifier:productIdentifier];
NSString *productTitle = product.localizedTitle;
int64_t priceInMicros = product.price.floatValue * 1000000; // FIXME: Doesn't consider different currencies
[gaiTransaction addItemWithCode:productIdentifier name:productTitle category:nil priceMicros:priceInMicros quantity:payment.quantity];
gaiTransaction.revenueMicros = priceInMicros * payment.quantity; // FIXME: doesn't consider Apple's cut
id<GAITracker> tracker = [GAI sharedInstance].defaultTracker;
[tracker trackTransaction:gaiTransaction];
}
以上是跟踪应用内购买的正确方法吗?我至少发现了两个问题:
SKProduct
返回本地化价格,如果我按原样跟踪它,收入汇总将不正确。有没有办法使价格正常化?- 返回的收入没有考虑苹果的削减,这并不总是 30%。是否有可能在应用程序内获得净收入?