Search code examples
swiftin-app-purchasefacebook-ios-sdkin-app-subscription

Facebook ios sdk doesn't track standard purchase events


I have auto-renewable subscriptions in my app. These subscriptions come with 3-7 days trial (money charged only after this trial period). I didn't place any custom code for event tracking in source files, and facebook tracks all of these events just fine, except purchases. I thought that was because I've never had purchase events untill today, but today somebody subscribed, and "purchase" event still not tracked. Instead "Initiated checkout" event was tracked with value = subscription price. enter image description here

Question is why it is not tracked? I am planning to create an advertising campaign with purchase events optimization in facebook, but if they are not recognized, then I can't do it.


Solution

  • Auto-renewable subscriptions can't be tracked by the Facebook SDK since the customer doesn't get charged in response to in-app events. Payment for your subscriptions occur after a trial conversion or on a renewal, and happen regardless of whether the user has your app open at the time.

    In order to accurately track auto-renewable subscriptions in Facebook, you'll need to save the purchase receipt from Apple on your server, and periodically refresh it with the /verifyReceipt endpoint. From this response you can determine if your free trial converted or the subscription renewed, then, finally, you can track the conversion through the Facebook API from your server.