Мы постоянно публикуем обновления документации, которые могут быть недоступны на вашем языке. Наиболее актуальные сведения содержатся в версии на английском языке.

Record events

You can associate your Adjust event tokens to actions in your app to measure them. To measure an event:

  1. Create a new Adjust event instance and pass your event token as a string argument.
  2. Call the trackEvent method with your event instance as an argument.
Swift
Objective-C
Javascript
let event = ADJEvent(eventToken: "abc123")
Adjust.trackEvent(event)

Example

Record event revenue

You can measure revenue associated with an event by setting the revenue and currency properties on your event instance. Use this feature to measure revenue-generating actions in your app.

To set these properties, call the setRevenue method and pass the following arguments:

  • The revenue amount (number)
  • The currency code (string)

You must format the currency code as a 3 character string that follows the ISO 4217 standard. The Adjust backend converts the reported revenue to your chosen reporting currency. Check our guide to tracking purchases in different currencies for more information.

Swift
Objective-C
Javascript
let event = ADJEvent(eventToken: "abc123")
event?.setRevenue(0.01, currency: "EUR")
Adjust.trackEvent(event)
Совет:
If you are measuring in-app purchases, call trackEvent only after the purchase is complete.

Example

Purchase verification

Примечание:

Purchase verification is an optional feature. These settings have no effect unless purchase verification is enabled.

If you've enabled purchase verification, you must send additional information with your purchase events to verify them. When Adjust's servers receive this information in an event object, they forward it to Apple to verify the purchase.

transactionId (NSString)
The transactionIdentifier value of the successfully completed purchase
productId (NSString)
The product identifier of the item that was successfully purchased
receipt (NSData)
The signed receipt containing the information about the successfully completed purchase
Swift
Objective-C
let receiptURL = Bundle.main.appStoreReceiptURL;
let receipt = try Data(contentsOf: receiptURL, options: .alwaysMapped)

let event = ADJEvent(eventToken: "abc123")
event?.setRevenue(6.0, currency: "EUR");
event?.setTransactionId("transaction-id");
event?.setProductId("product-id");
event?.setReceipt(receipt);
Adjust.trackEvent(event)

Add callback parameters

If you register a callback URL for your events in the Adjust dashboard, Adjust sends a GET request to your callback URL when the SDK measures an event.

You can configure callback parameters to your servers. Once you configure parameters on an event, the SDK appends them to your callback URL. You can use this information to analyse your users' in-app behavior with your BI system.

Add callback parameters to your event by calling the addCallbackParameter method with string key-value arguments. You can add multiple parameters by calling this method multiple times.

Objective-C
Swift
Javascript
ADJEvent *event = [ADJEvent eventWithEventToken:@"abc123"];
[event addCallbackParameter:@"key" value:@"value"];
[event addCallbackParameter:@"foo" value:@"bar"];
[Adjust trackEvent:event];

The Adjust SDK measures the event and sends a request to your URL with the callback parameters. For example, if you register the URL http://www.mydomain.com/callback, your callback looks like this:

http://www.mydomain.com/callback?key=value&foo=bar

If you are using CSV uploads, make sure to add the parameters to your CSV definition.

Adjust supports many placeholders which you can use to pass information from the SDK to your URL. For example, the {idfa} placeholder for iOS and the {gps_adid} placeholder for Android. The {publisher_parameter} placeholder presents all callback parameters in a single string.

Подробнее об использовании URL-адресов колбэков, включая полный список доступных значений, см. в нашем руководстве по колбэкам.

Примечание:
Adjust не хранит ваши настраиваемые параметры колбэка. Они добавляются только к URL-адресу колбэка.

Example

Add partner parameters

You can send extra information to your network partners by adding partner parameters.

Adjust sends partner parameters to external partners you have set up. This information is useful for more granular analysis and retargeting purposes. The backend forwards these parameters once you have set them up and enabled them for a partner.

Примечание:
Partner parameters do not appear in raw data by default. You can add the {partner_parameters} placeholder to receive them as a single string.

Add partner parameters to your event by calling the addPartnerParameter method with string key-value arguments. You can add multiple parameters by calling this method multiple times.

Swift
Objective-C
Javascript
let event = ADJEvent(eventToken: "abc123")
event?.addPartnerParameter("key", value: "value")
event?.addPartnerParameter("foo", value: "bar")
Adjust.trackEvent(event)

Example

Add a callback identifier

You can add a custom string identifier to each event you want to measure. The Adjust backend can report on this identifier in event callbacks. This enables you to keep track of which events have been successfully measured.

Set up this identifier by calling the setCallbackId method with your ID as a string argument.

Swift
Objective-C
Javascript
let event = ADJEvent(eventToken: "abc123")
event?.setCallbackId("Your-Custom-ID")
Adjust.trackEvent(event)

Example