Integrations

Adapty can send your users events to a webhook or third-part analytics

Getting started

Adapty receives your app's receipts from Apple and converts them to human-readable JSONs.

Here is an example of a receipt that we get:

{
"latest_receipt":"",
"latest_receipt_info":
{
"original_purchase_date_pst":"2018-03-17 15:01:52 America/Los_Angeles",
"quantity":"1",
"subscription_group_identifier":"19876965",
"unique_vendor_identifier":"429ABA42-10CB-4444-9505-CB57B99480AB",
"original_purchase_date_ms":"1521324112000",
"expires_date_formatted":"2019-12-11 10:32:27 Etc/GMT",
"is_in_intro_offer_period":"false",
"purchase_date_ms":"1573468347000",
"expires_date_formatted_pst":"2019-12-11 02:32:27 America/Los_Angeles",
"is_trial_period":"false",
"item_id":"949266578",
"unique_identifier":"83175a063fa4bb1430d17687aee92eba700c4999",
"original_transaction_id":"540000256834273",
"expires_date":"1576060347000",
"app_item_id":"582671477",
"transaction_id":"540000438969009",
"bvrs":"4",
"web_order_line_item_id":"540000143534057",
"version_external_identifier":"823948547",
"bid":"com.easy10.ru-en",
"product_id":"1_month_subscription_PREMIUM_trial",
"purchase_date":"2019-11-11 10:32:27 Etc/GMT",
"purchase_date_pst":"2019-11-11 02:32:27 America/Los_Angeles",
"original_purchase_date":"2018-03-17 22:01:52 Etc/GMT"
},
"environment":"PROD",
"auto_renew_status":"true",
"auto_renew_product_id":"1_month_subscription_PREMIUM_trial",
"notification_type":"RENEWAL"
}

Currently Adapty has 7 types of events:

  1. subscription_initital_purchase — user has activated a subscription without a trial period i.e. he was billed instantly

  2. trial_started — user has activated a trial subscription

  3. trial_converted — trial period has ended and user was billed i.e. first purchase was made

  4. trial_cancelled — user has cancelled a trial before being billed

  5. subscription_renewed — subscription was renewed and user was charged. For both trial and non-trial subscriptions this event is sent starting from the second billing

  6. subscription_cancelled — user has cancelled a subscription

  7. non_subscription_purchase — any non-subscription purchase e.g. lifetime access or consumable product such as coins

Each event has a structure similar to:

{
"product_id": "1_month_subscription_PREMIUM_trial",
"transaction_id": "340000183250708",
"original_transaction_id": "20000421557200",
"purchase_date": "2017-09-26 14:18:09.453000 +00:00",
"original_purchase_date":"2017-04-26 11:03:24.673000 +00:00",
"consecutive_payments": 6,
"price_usd": 29.99,
"proceeds_usd": 19.99,
"rate_after_first_year": false
}
  • product_id — id of your product in App Store Connect

  • transaction_id — id of a current transaction

  • original_transaction_id — id of an original transaction in the chain of transactions. For example, if a user was billed 10 times, transaction_id will be an id of 10th charge while original_transaction_id is an id of the 1st transaction

  • purchase_date — datetime with timezone of a purchase in a format %Y-%m-%d %H:%M:%S %z

  • original_purchase_date — purchase_date of an original transaction

  • consecutive_payments — number of times a user was billed. For example, if a user was billed 9 times the current transaction will have consecutive_payments=10

  • price_usd — product price that's equal to App Store Connect price

  • proceeds_usd — developer's revenue will get after Apple commission

  • rate_after_first_year — whether a user is subscribed for more than a year. After 1 year of being subscribed Apple reduces commission

Each event has different properties:

Event Name

product_id

transaction_id

original_transaction_id

purchase_date

original_purchase_date

consecutive_payments

price_usd

proceeds_usd

rate_after_first_year

subscription_initital_purchase

trial_started

trial_converted

trial_cancelled

subscription_renewed

subscription_cancelled

non_subscription_purchase

Integrations

Adapty can send events listed above to Mixpanel, Amplitude, Facebook Analytics and your custom Webhook.

Webhook

Webhook setup

When you set a Webhook, Adapty sends a POST verification event in a format:

{
adapty_check: check_string
}

where check_string is any string. For example, it can be uuid4 casted to string, such as ff822d92-823b-42a7-979f-82686f73e862.

Your server must respond with 200 or 201 code and return event containing:

{
adapty_check_response: check_string
}

with the same check_string

After that Adapty sends POST events about your subscribers, as listed above in a format:

{
user_id: user_id,
event_type: event_type,
event_properties: event_info
}

Where:

  • user_id — is either your user id that you've set using our mobile SDK or Adapty's internal id if you haven't

  • event_type — one of seven event names listed above

  • event_properties — dictionary with event properties

Mixpanel

Adapty maps several properties such as user id and revenue of the event to Mixpanel-native properties. With such mapping Mixpanel is able to show you correct data in the profile and events' timeline.

  1. Find your Mixpanel token in the official help.

  2. Paste into Adapty interface and Save

You can also change event mapping to how they appear in Mixpanel.

Amplitude

In the same way as Mixpanel, Adapty maps properties to Amplitude-native properties.

You also need to find a key and then save it to Adapty.

Facebook

You need an application on Facebook Developers platform. Log in into your app and then find advanced settings.

Scroll down and find a Client Token. Also find App id in the header.

App ID and Client Token