上传应用内收入事件

传输关于购买的数据。

使用示例:如果您的应用中的购买不是通过 Google Play 或 AppStore 完成,也没有在客户端进行跟踪,您可以通过 Post API 将 In-App 收入事件发送到 Analytics module。 如果您自行在应用内跟踪订阅数据或使用第三方服务,您可以通过 Post API 传输订阅数据。

通过 Post API 接收的购买事件用于计算所有指标,也可在漏斗和分群中使用。

通过 Post API 接收的收入事件不会被验证,总是被视为有效。

事件属性可以通过参数或请求体传递。 当您在正文中传递数据时,应将.csv添加到请求的URL中。 要了解更多信息,请查看示例请求。

要将事件绑定到用户,请在请求中使用以下字段之一:

  • profile_id
  • appmetrica 设备 ID

Post API 有数据加载限制。 要了解更多信息,请查看限制。

请求格式

提交 https://api.boost.yandex.com/logs/v1/import/revenue
  ? post_api_key=<string>
  & application_id=<int>
  & profile_id=<string>
  & appmetrica_device_id=<int>
  & revenue_event_type=<string>
  & event_timestamp=<int>
  & price=<decimal>
  & currency=<string>
  & product_id=<string>
  & [quantity=<int>]
  & [payload=<string>]
  & [transaction_id=<int>]
  & [order_id=<int>]
  & [session_type=<string>]
  & [ios_ifa=<string>]
  & [ios_ifv=<string>]
  & [google_aid=<string>]
  & [windows_aid=<string>]
  & [os_name=<string>]
  & [os_version=<string>]
  & [device_manufacturer=<string>]
  & [device_model=<string>]
  & [device_type=<string>]
  & [device_locale=<string>]
  & [app_version_name=<string>]
  & [app_package_name=<string>]
  & [connection_type=<string>]
  & [operator_name=<string>]
  & [mcc=<int>]
  & [mnc=<int>]
  & [device_ipv6=<string>]

post API 密钥*

用于数据上传的令牌。 您可以在应用的 设置 部分获取它。

应用ID*

应用在 Analytics module 中的唯一数字标识符。

profile_id*

用户个人资料 ID。 Post API 仅允许您上传先前通过 SDK 发送的标识符的数据。

不要传递 appmetrica_device_id 参数的值。 服务器只接受这些参数中的一个。

appmetrica_device_id*

Analytics module 设置的设备唯一标识符的哈希。 Post API 仅允许您上传先前通过 SDK 发送的标识符的数据。

不要传递 profile_id 参数的值。 服务器只接受这些参数中的一个。

收入事件类型*

购买事件类型。 可用类型列表:

  • one_time_purchase:进行一次性购买。
  • trial_started:开始带试用期的订阅。
  • intro_started:开始带介绍性优惠的订阅。
  • promo_started:开始带促销优惠的订阅。
  • subscription_converted:在介绍性优惠后支付全额订阅费用。
  • subscription_started:开始不带介绍性优惠的订阅。
  • subscription_renewed:支付新的订阅期费用。
  • cancellation:取消订阅。 在此事件之后,用户可能还有付费期,但不会再收取费用。
  • uncancellation:来自 Apple ID 设置的订阅激活事件。
  • expired:订阅已过期。
  • billing_issues:支付订阅续订时出错。
  • refund:退还订阅或一次性购买。

event_timestamp*

事件的时间,格式为 Unix time。

使用 Post API,您只能在事件日期(event_timestamp)与上传日期之间的差异不超过 14 天时上传事件。 API 期望以秒为单位的值。

价格*

价格。 收入金额,格式为 decimal(10.8)(小数点前 10 位、小数点后 8 位的十进制小数)。

货币

购买的货币。 可用货币列表. 三字元货币代码以大写字母传递。

product_id

商品 ID。

数量

购买的产品数量。默认值: 1.

payload

任意负载:以键值对形式呈现的附加信息。 最大大小为 30 KB。 如果值超过此限制,Analytics module 将截断它。

transaction_id

唯一交易 ID。

order_id

订单 ID。

session_type

会话类型。 可能的值:

  • 前景 — 在 事件 报告中Analytics module 提高了 用户 指标。
  • 背景 — 在 事件 报告中 Analytics module 增加了 设备 指标。 这样的事件不会被包含在按用户分组的报告中,也不会出现在用户档案卡中。

Default value is 背景.

ios_ifa

设备的 IFA,格式为从设备接收的格式。

ios_ifv

应用的 IFV,格式为从设备接收的格式。

google_aid

设备的 Google AID,格式为从设备接收的格式。

windows_aid

设备的 Windows AID,格式为从设备接收的格式。

os_name

用户设备上的操作系统:ios | android | windows。

os_version

用户设备上的操作系统版本。

设备制造商

Analytics 服务检测到的设备制造商(例如,Apple 或 Samsung)。

device_type

Analytics 服务检测到的设备类型。 可能的值:phone | tablet | unknown。

device_locale

设备上的语言。

app_version_name

开发者指定的应用版本格式。

app_package_name

Android 的包名,或 iOS 的 Bundle ID(例如,ru.yandex.metro)。

连接类型

连接类型。 可能的值:wifi | cell | unknown。

operator_name

移动运营商名称。

mcc

移动国家代码。

mnc

移动网络代码。

device_ipv6

事件时的 IP 地址,格式为 IPv6。 例如,2a02:6b8::40c:6676:baff:fea6:53d8, ::ffff:5.255.232.147。

Response codes

Code 描述
200 数据已成功上传。
403 请求缺少授权头,或者指定的令牌无效。
400 请求缺少一个或多个必需参数。

示例请求

POST /logs/v1/import/revenue.csv?post_api_key=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ012 HTTP/1.1
Host: api.boost.yandex.com
Content-Length: 540i
Connection: close

appmetrica_device_id,device_model,device_type,google_aid,app_package_name,operator_name,mnc,application_id,account_id,event_timestamp,price,currency,product_id,quantity,transaction_id,order_id,revenue_event_type
1757762239877245682,iPhone X,phone,01234567-890a-bcde-f012-3456789abcde,com.yandex.sample.metrica,MegaFon,2,1111,1234567890123456789,1689943892,0.0001,USD,some_product1,1,transact1,8101,promo_started
1757762239877245682,iPhone X,phone,76543210-890a-bcde-f012-3456789abcde,com.yandex.sample.metrica,MegaFon,2,1111,9876543210987654321,1689943892,0.0001,USD,some_product2,2,transact2,1234,expired
POST /logs/v1/import/revenue?post_api_key=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ012&appmetrica_device_id=1757762239877245682&device_model=iPhoneX&device_type=phone&google_aid=01234567-890a-bcde-f012-3456789abcde&app_package_name=com.yandex.sample.metrica&operator_name=MegaFon&mnc=2&application_id=1111&account_id=1234567890123456789&event_timestamp=1689943892&price=0.0001&currency=USD&product_id=some_product1&quantity=1&transaction_id=transact1&order_id=8101&revenue_event_type=promo_started HTTP/1.1
Host: api.boost.yandex.com
Content-Length: 0
Connection: close

其他 Post API 方法

如果您没有找到所需答案,可以通过反馈表单提交您的问题。 请尽可能详细地描述问题。 如果可能,请附上截图。

联系支持 建议改进文档