Import payments

To send payments to MyTracker, use the following methods:

  • customRevenue and customRevenueBatch for custom revenue
  • googlePlayProductTransaction, googlePlaySubscriptionTransaction and googlePlaySubscriptionToken for Google Play in-app purchases and subscriptions
  • appStoreProductTransaction, appStoreSubscriptionTransaction, and appStoreSubscriptionReceipt for App Store in-app purchases and subscriptions

Google Play payments

MyTracker can track in-app purchases and subscriptions automatically (see the Revenue tracking section). But if the automatic tracking is not enough, or there are problems, you can upload payments using the S2S API.

Let's consider some examples of using S2S API methods:

Example 1 — Import historical data on purchases

When MyTracker has no data on in-app purchases, for example, made before MyTracker SDK integration, use the method googlePlayProductTransaction.


Example 2 — Import historical data on subscriptions

When MyTracker has no data on subscriptions, for example, made before the MyTracker SDK integration:

  1. Import historical data using googlePlaySubscriptionTransaction
  2. Enable tracking of future renewals using googlePlaySubscriptionToken

Example 3 — Track active subscriptions

If MyTracker does not track a subscription automatically (for example, subscription made before the MyTracker SDK integration):

  1. Import historical data using googlePlaySubscriptionTransaction
  2. Enable renewals tracking using googlePlaySubscriptionToken

Example 4 — Import data after configuring a verification

If you took a while to add the verification key to MyTracker, and as a consequence, did not verify the first payments:

  1. Ensure you add Google Play credentials to MyTracker.
  2. Import lacking purchase data using googlePlayProductTransaction
  3. Import lacking subscription data using googlePlaySubscriptionTransaction
  4. Enable subscription tracking using googlePlaySubscriptionToken

Example 5 — Import data after tracking failure

When MyTracker has no data on purchases and subscriptions due to a failed update to the app and a broken tracking setting:

  1. Import lacking purchase data using googlePlayProductTransaction
  2. Import lacking subscription data using googlePlaySubscriptionTransaction
  3. Enable subscription tracking using googlePlaySubscriptionToken

If you retransmitted data or loaded previously tracked transactions, there will be no error because MyTracker removes duplicates

googlePlayProductTransaction

Use the googlePlayProductTransaction method to send Google Play in-app purchases.

MyTracker will send a purchase confirmation request to the Google Play API for each passed transaction. If the payment is valid, MyTracker will classify the purchase as a verified transaction; if not, the transaction will be saved as unverified.

Import historical data on purchases in chronological order, otherwise, the information on the first payments will be distorted.

End-point: https://tracker-s2s.my.com/v1/googlePlayProductTransaction/?idApp=XXX

Required parameter: a user identifier customUserId and/or one of the device identifiers: instanceId, gaid, androidId, appSetId (transactions will be related to the user and/or the device), eventTimestamp, as well as parameters from the table below.

Name Description Type Example
orderId* Transaction identifier String "orderId": "1234-1234-1234-12345"
productId* The purchased product identifier String "productId": "001"
token* The token provided to the user's device when the product was purchased String "token": "ofjkingojelmkmedpgfkfelj"
currency* Payment currency String "currency": "USD"
revenue* Payment amount in the specified currency String "revenue": "4.9"

* — required parameter.

googlePlaySubscriptionTransaction

Use the googlePlaySubscriptionTransaction method to send Google Play subscription transactions.

Import historical data on subscriptions in chronological order, otherwise, the information on the first payments will be distorted.

End-point: https://tracker-s2s.my.com/v1/googlePlaySubscriptionTransaction/?idApp=XXX

Required parameters: a user identifier customUserId and/or one of the device identifiers: instanceId, gaid, androidId, appSetId (transactions will be related to the user and/or the device), eventTimestamp, as well as parameters from the table below.

Name Description Type Example
orderId* Transaction identifier String "orderId": "1234-1234-1234-12345"
priceCurrencyCode* Payment currency String "priceCurrencyCode": "USD"
priceAmountMicros* Price of the subscription expressed in micro-units, where 1,000,000 micro-units represents one unit of the currency. For example, if the subscription price is €1.99, priceAmountMicros is 1990000. Integer "priceAmountMicros": "1990000"
subscriptionId* The purchased subscription identifier String "subscriptionId": "monthly001"
paymentState The payment state of the subscription:
1 — received
2 — trial

Default value: 1
String "paymentState": "1"
isIntroductory Introductory price information of the subscription:
0 — regular price
1 — introductory price

Default value: 0
Integer "isIntroductory": "1"
startTimeMillis Time at which the subscription was granted, in milliseconds Integer "startTimeMillis": "1693242344000"
expiryTimeMillis Time at which the subscription will expire (after this transaction), in milliseconds Integer "expiryTimeMillis": "1693242344000"

* — required parameter.

googlePlaySubscriptionToken

Use the googlePlaySubscriptionToken method to send information about an active subscription. Based on the passed subscription ID, MyTracker will detect the latest renewal and track future renewals automatically.

All future subscription payments will be are related to the device and user that you specify in the method

We recommend you pass the subscriptionPeriod parameter. With this parameter, MyTracker will be able to calculate the time of the latest renewal, and in the future, will be able to time renewals even if Google Play delays data. Without subscriptionPeriod, the latest renewal and all further renewals will be logged at the moment of data receipt from Google Play.

End-point: https://tracker-s2s.my.com/v1/googlePlaySubscriptionToken/?idApp=XXX

Required parameter: a user identifier customUserId and/or one of the device identifiers: instanceId, gaid, androidId, appSetId (transactions will be related to the user and/or the device), as well as parameters from the table below.

Name Description Type Example
orderId* Transaction identifier String "orderId": "GPA.1234-1234-1234-12345"
subscriptionId* The purchased subscription identifier String "subscriptionId": "monthly001"
token* The token provided to the user's device when the subscription was purchased String "token": "ofjkingojelmkmedpgfkfelj"
subscriptionPeriod Subscription period in ISO 8601 format, for example:
P1W — one week
P1M — one month
P3M — three months
P6M — six months
P1Y — one year
String "subscriptionPeriod": "P6M"

* — required parameter.

App Store payments

MyTracker can track in-app purchases and subscriptions automatically (see the Revenue tracking section). But if the automatic tracking is not enough, or there are problems, you can upload payments using the S2S API.

Let's consider some examples of using S2S API methods:

Example 1 — Import historical data on purchases

When MyTracker has no data on in-app purchases, for example, made before MyTracker SDK integration, use the method appStoreProductTransaction.


Example 2 — Import historical data on subscriptions

When MyTracker has no data on subscriptions, for example, made before the MyTracker SDK integration:

  1. Import historical data using appStoreSubscriptionTransaction.
  2. Send the receipt for the active subscriptions using appStoreSubscriptionReceipt.

Example 3 — Track active subscriptions

If MyTracker does not track a subscription automatically, for example, subscription made before the MyTracker SDK integration, import subscription data using appStoreSubscriptionReceipt.


Example 4 — Import data after configuring a verification

If you took a while to add the verification key to MyTracker, and as a consequence, missed some of the renewals:

  1. Ensure you add App Store credentials to MyTracker.
  2. Import lacking subscription data using appStoreSubscriptionTransaction.
  3. Enable subscription tracking using appStoreSubscriptionReceipt.

Example 5 — Import data after tracking failure

When MyTracker has no data on purchases and subscriptions due to a failed update to the app and a broken tracking setting:

  1. Import lacking purchase data using appStoreProductTransaction.
  2. Import lacking subscription data using appStoreSubscriptionTransaction.
  3. Enable subscription tracking using appStoreSubscriptionReceipt.

If you retransmitted data or loaded previously tracked transactions, there will be no error because MyTracker removes duplicates

appStoreProductTransaction

The appStoreProductTransaction method is in beta testing. If you have any questions, please contact our support team

Use the appStoreProductTransaction method to send App Store in-app purchases. All uploaded payments will be saved in MyTracker as verified transactions.

Import historical data on purchases in chronological order, otherwise, the information on the first payments will be distorted.

End-point: https://tracker-s2s.my.com/v1/appStoreProductTransaction/?idApp=XXX

Required parameters: a user identifier customUserId and/or one of the device identifiers: instanceId, idfa, iosVendorId (transactions will be related to the user and/or the device), eventTimestamp, as well as parameters from the table below.

Name Description Type Example
transactionId* Transaction identifier String "transactionId": "1234567890098765"
productId* The purchased product identifier String "productId": "001"
price* Price of the product Float "price": "1.99"
currency* Payment currency String "currency": "USD"
quantity The number of products purchased
Default value: 1
Integer "quantity": "1"

* — required parameter.

appStoreSubscriptionTransaction

The appStoreSubscriptionTransaction method is in beta testing. If you have any questions, please contact our support team

Use the appStoreSubscriptionTransaction method to send App Store subscription transactions.

Import historical data on subscriptions in chronological order, otherwise, the information on the first payments will be distorted.

End-point: https://tracker-s2s.my.com/v1/appStoreSubscriptionTransaction/?idApp=XXX

Required parameters: a user identifier customUserId and/or one of the device identifiers: instanceId, idfa, iosVendorId (transactions will be related to the user and/or the device), eventTimestamp, as well as parameters from the table below.

Name Description Type Example
transactionId* Transaction identifier String "transactionId": "1234567890098765"
productId* The purchased subscription identifier String "productId": "monthly001"
price* Price of the product Float "price": "1.99"
currency* Payment currency String "currency": "USD"
transactionIdOriginal* Original transaction identifier (the first transaction in the subscription). String "transactionIdOriginal": "1234567890098765"
isTrial Trial subscription:
0 — no
1 — yes

Default value: 0
Integer "isTrial": "1"
isIntroductory Introductory price information of the subscription:
0 — regular price
1 — introductory price

Default value: 0
Integer "isIntroductory": "1"
tsPaymentOriginal Time at which the subscription was granted Integer "tsPaymentOriginal": " 1643453453"
tsPaymentExpires Time at which the subscription will expire (after this transaction) Integer "tsPaymentExpires": "1643453453"
quantity The number of products purchased
Default value: 1
Integer "quantity": "1"

* — required parameter.

appStoreSubscriptionReceipt

The appStoreSubscriptionReceipt method is in beta testing. If you have any questions, please contact our support team

Use the appStoreSubscriptionReceipt method to send information about an active subscription. Based on the passed receipt, MyTracker will send a request to the App Store API, get historical subscription transactions and track future renewals automatically.

All in-app purchases and subscriptions from the receipt will be related to the device or/and user that you specify in the method

End-point: https://tracker-s2s.my.com/v1/appStoreSubscriptionReceipt/?idApp=XXX

Required parameters: a user identifier customUserId and/or one of the device identifiers: instanceId, idfa, iosVendorId (transactions will be related to the user and/or the device), as well as parameters from the table below.

Name Description Type Example
transactionId* Transaction identifier String "transactionId": "1234567890098765"
productId* The purchased product identifier String "productId": "com.abc.def"
receipt* Payment receipt in base64 format String "receipt": "aaabbcbcac=="
price* Price of the product Float "price": "9.99"
currency* Payment currency String "currency": "USD"

* — required parameter.

Custom revenue

Custom revenue involves other payment transactions that cannot be sent as ads revenue, in-app payments, or subscriptions. For example, it may be offline purchases or WeChat payments. In other words, it is any revenue for which there is not yet another mechanism for collecting data.

You can send custom revenue only via S2S API, using customRevenue and customRevenueBatch methods.

customRevenue

Use the customRevenue method to send data on a custom payment. It may be any payment that couldn't pass to MyTracker as ad revenue, an in-app payment, or a subscription. Like an offline purchase or a payment via WeChat Pay. For details, please refer to the Revenue tracking section.

End-point: https://tracker-s2s.my.com/v1/customRevenue/?idApp=XXX

Required parameters: a user identifier customUserId and/or one of the device identifiers instanceId, lvid, gaid, androidId, idfa, iosVendorId (transactions will be related to the user and/or the device), eventTimestamp, as well as parameters from the table below.

Name Description Type Example
idTransaction* Transaction identifier unique in the project String, minimum length 1, maximum length 255 "idTransaction": "order1234"
currency* The numeric code assigned to a currency by ISO 4217 String, length 3 symbols "currency": "USD"
total* Amount of payment Nonintegral, minimum value 0 "total": 1.99

* — required parameter.

customRevenueBatch

Use the customRevenueBatch method to send batch data. This method is similar to customRevenue but lets you send more than one payment.

End-point: https://tracker-s2s.my.com/v1/customRevenueBatch/?idApp=XXX

Required parameters:

Name Description Type Example
One parameter without a name. It's an array, through which you can pass parameters from the customRevenue method.
If validation rules are broken in at least one set of parameters, the server will return the error
Array. Maximum size 20 [
{"customUserId": "1111", "lvid":"00000000000000000000000000000000", "idTransaction": "order1", "currency":"USD", "total": 1.99},
{"customUserId": "2222", "lvid":"00000000000000000000000000000000", "idTransaction": "order2", "currency":"USD", "total": 10.99}
]

Parameters

All parameters are passed in the request body in JSON format.

Limit on the maximum size of imported data — 10Kb.

Name Description Type Example

Common

eventTimestamp Event time Number, minimum value 946674000, maximum value 4294967295. By default, timestamp of receiving the event "eventTimestamp":"1577191920"
customUserId User identifier in your app String, maximum size 1024 "customUserId":"1234"
ipv4 ipv4 address String, maximum size 15 "ipv4":"125.125.125.125"
ipv6 ipv6 address String, maximum size 45 "ipv6":"2001:0db8:85a3:0000:0000:8a2e:0370:7334"
idGender Gender Number, possible values:
  • 0 — unknown
  • 1 — man
  • 2 — woman
"idGender":"1"
age Age Number, maximum value 128 "age":"38"
connectionType Connection type Number, possible values:
  • 0 — unknown
  • 1 — mobile
  • 2 — wi-fi
By default, 0
"connectionType":"1"
bluetoothEnabled Bluetooth Number, possible values:
  • 0 — unknown
  • 1 — on
  • 2 — off
By default, 0
"bluetoothEnabled":"2"

For mobile platform

instanceId S2S device identifier String, number of symbols 36 "instanceId":"00000000-0000-0000-0000-000000000000"
adTrackingEnabled Tracking permission Number, possible values:
  • 1 — on
  • 0 — off
By default, 1
"adTrackingEnabled":"0"
iOS
idfa iOS advertising identifier String, number of symbols 36 "idfa":"00000000-0000-0000-0000-000000000000"
iosVendorId iOS vendor identifier String, number of symbols 36 "iosVendorId":"00000000-0000-0000-0000-000000000000"
Android
gaid Android advertising identifier String, number of symbols 36 "gaid":"00000000-0000-0000-0000-000000000000"
appSetId Android identifier, unique within a Google Play developer account String, number of symbols 36 "appSetId":"00000000-0000-0000-0000-000000000000"
androidId Android identifier String, number of symbols 16 "androidId":"000000000000000"

For Web platform

lvid S2S device identifier String, number of symbols 32 "lvid":"00000000000000000000000000000000"
adBlocker Ad blocker Number, possible values:
  • 1 — on
  • 0 — off
By default, 0
"adBlocker":"0"
userAgent User-Agent String, maximum size 2048 "userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.87 Safari/537.36"

Example query

HTTP POST request:

curl https://tracker-s2s.my.com/v1/customRevenue/?idApp=666 \
–k –X POST --header "Authorization: aaaaaAAAaaa01aaaaaaa1aaAAA11a" \
-d '{"customUserId": "1", "idTransaction": "order1234",
"currency": "USD", "total": 1.99, "eventTimestamp": "1580213208",
"instanceId": "00000000-0000-0000-0000-000000000000"}'

Status codes

Code Text Description
200 {"message": "ОK"} The request was successfully processed
400 {"error": "Bad Request"} Request error, parameters not validated
403 {"error": "Forbidden"} The token has not been validated or is not suitable for the application
400 {"error": "Empty post data"} Empty request body
400 {"error": "Bad json"} Passed an invalid JSON file in the request body
400 {"error": "Bad api version"} Unsupported API version
400 {"error": "Platform is not supported in this method. Please, use googlePlay* methods for Android and appStore* methods for iOS"} Platform is not supported in this method. Please, use googlePlay* methods for Android and appStore* methods for iOS
404 {"error": "Method not found"} API method not found
500 {"error": "Internal Server Error"} Internal API error. Try to repeat the request later