Adjust SDK가 제공하는 AdjustEvent
객체는 이벤트 정보를 구성하고 이러한 정보를 앱에서 Adjust 서버로 전송하는 데 사용할 수 있습니다.
AdjustEvent 객체 인스턴스화
AdjustEvent(string eventToken)
Adjust SDK를 사용하여 이벤트 정보를 전송하려면 AdjustEvent
객체를 인스턴스화해야 합니다. 이 객체에는 앱에서 이벤트가 발생할 때 Adjust로 전송되는 변수가 포함됩니다.
이벤트 객체를 인스턴스화하려면 새로운 AdjustEvent
인스턴스를 생성하고 다음 파라미터를 전달합니다.
eventToken
(String
): Adjust 이벤트 토큰
AdjustEvent myAdjustEvent = new AdjustEvent('abc123');//...Adjust.trackEvent(myAdjustEvent);
이벤트 전송
static void trackEvent(AdjustEvent event)
Adjust 이벤트 토큰을 연결하여 앱의 이벤트를 기록할 수 있습니다. 이벤트 기록 방법:
- 새 Adjust 이벤트 인스턴스를 만들고 이벤트 토큰을 문자열 인수로 전달합니다.
- 이벤트 인스턴스를 인수로
trackEvent
메서드를 호출합니다.
AdjustEvent myAdjustEvent = new AdjustEvent('abc123');//...Adjust.trackEvent(myAdjustEvent);
예
본 예시에서는 사용자가 버튼을 조작할 때마다 g3mfiw
라는 토큰으로 이벤트를 기록하는 방법을 보여줍니다.
import 'package:adjust_sdk/adjust_event.dart';import 'package:flutter/cupertino.dart';import 'package:flutter/material.dart';
class Util { static const String EVENT_TOKEN_SIMPLE = 'g3mfiw';
static Widget buildCupertinoButton(String text, Function action) { return new CupertinoButton( child: Text(text), color: CupertinoColors.activeBlue, padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 30.0), onPressed: action as void Function()?, ); }
static AdjustEvent myAdjustEvent() { return new AdjustEvent(EVENT_TOKEN_SIMPLE); }}
// main.dartimport 'util.dart';
Util.buildCupertinoButton('Track Simple Event', () => Adjust.trackEvent(Util.myAdjustEvent())),const Padding(padding: const EdgeInsets.all(7.0))
Path: /eventClientSdk: flutter$FLUTTER_VERSIONParameters: android_uuid 781f17d5-5048-4fae-a4e5-77b58bab62b9 api_level 3441 collapsed lines
app_token 2fm9gkqubvpc app_version 1.0 attribution_deeplink 1 callback_params {"key":"value","foo":"bar"} connectivity_type 1 country US cpu_type arm64-v8a created_at 2024-01-25T14:13:16.151Z+0100 currency EUR device_manufacturer Google device_name sdk_gphone64_arm64 device_type phone display_height 2205 display_width 1080 environment sandbox event_buffering_enabled 0 event_count 3 event_token g3mfiw gps_adid 5962dfc1-3a53-4692-850b-22c4bf4311a5 gps_adid_attempt 2 gps_adid_src service hardware_name UE1A.230829.036 language en mcc 310 mnc 260 needs_response_details 1 os_build UE1A.230829.036 os_name android os_version 14 package_name com.adjust.examples partner_params {"key":"value","foo":"bar"} revenue 0.25 screen_density high screen_format long screen_size normal session_count 2 session_length 23 subsession_count 1 time_spent 23 tracking_enabled 1 ui_mode 1
매출 이벤트 기록
void setRevenue(Num revenue, String currency)
이벤트 인스턴스에서 매출 및 통화 속성을 설정하여 이벤트 관련 매출을 기록할 수 있습니다. 이 기능을 사용하여 앱 내에서 매출을 발생시키는 행동을 측정하시기 바랍니다.
이러한 속성을 설정하려면 setRevenue
메서드를 호출하고 다음 인수를 전달합니다.
revenue
(num
): 해당 이벤트에 의해 창출된 매출 금액currency
(String
): 이벤트 통화의 ISO 4217 코드
AdjustEvent myAdjustEvent = new AdjustEvent('abc123');//...adjustEvent.setRevenue(0.01, 'EUR');//...Adjust.trackEvent(myAdjustEvent);
예
본 예시에서는 사용자가 버튼을 조작할 때마다 g3mfiw
라는 토큰으로 이벤트를 기록하는 방법을 보여줍니다. 이 함수는 이벤트의 revenue
속성을 0.25
, currency
속성을 EUR
로 설정합니다.
import 'package:adjust_sdk/adjust_event.dart';import 'package:flutter/cupertino.dart';import 'package:flutter/material.dart';
class Util { static const String EVENT_TOKEN_REVENUE = 'g3mfiw';
static Widget buildCupertinoButton(String text, Function action) { return new CupertinoButton( child: Text(text), color: CupertinoColors.activeBlue, padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 30.0), onPressed: action as void Function()?, ); }
static AdjustEvent myAdjustEvent() { AdjustEvent event = new AdjustEvent(EVENT_TOKEN_REVENUE); event.setRevenue(0.25, 'EUR'); return event; }
}
// main.dartimport 'util.dart';
// Send revenue event button.Util.buildCupertinoButton('Send Revenue Event', () => Adjust.trackEvent(Util.myAdjustEvent())),const Padding(padding: const EdgeInsets.all(7.0))
Path: /eventClientSdk: flutter$FLUTTER_VERSIONParameters: environment sandbox event_count 3 event_token abc123 revenue 0.25 currency EUR
매출 이벤트 중복 제거
String? transactionId;
중복 이벤트 기록을 방지하기 위해 선택적 ID를 전달할 수 있습니다. SDK는 최근순으로 10개의 ID를 저장하고, 중복된 트랜잭션 ID가 있는 매출 이벤트를 건너뜁니다.
식별자를 설정하려면 트랜잭션 ID를 이벤트 인스턴스의 setTransactionId
속성에 할당합니다.
AdjustEvent myAdjustEvent = new AdjustEvent('abc123');//...myAdjustEvent.transactionId = '{TransactionId}';//...Adjust.trackEvent(myAdjustEvent);
예
본 예시에서는 사용자가 버튼을 조작할 때마다 g3mfiw
라는 토큰으로 이벤트를 기록하는 방법을 보여줍니다. 이 함수는 setTransactionId
메서드를 사용하여 uniqueId
를 5e85484b-1ebc-4141-aab7-25b869e54c49
로 설정합니다.
import 'package:adjust_sdk/adjust_event.dart';import 'package:flutter/cupertino.dart';import 'package:flutter/material.dart';
class Util { static const String EVENT_TOKEN_REVENUE = 'g3mfiw'; static const String UNIQUE_ID = '5e85484b-1ebc-4141-aab7-25b869e54c49';
static Widget buildCupertinoButton(String text, Function action) { return new CupertinoButton( child: Text(text), color: CupertinoColors.activeBlue, padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 30.0), onPressed: action as void Function()?, ); }
static AdjustEvent myAdjustEvent() { AdjustEvent event = new AdjustEvent(EVENT_TOKEN_REVENUE); event.transactionId = UNIQUE_ID; return event; }
}
// main.dartimport 'util.dart';
// Send revenue event button.Util.buildCupertinoButton('Send Revenue Event', () => Adjust.trackEvent(Util.myAdjustEvent())),const Padding(padding: const EdgeInsets.all(7.0))
Path: /eventClientSdk: flutter$FLUTTER_VERSIONParameters: environment sandbox event_count 3 event_token abc123 transaction_id 5e85484b-1ebc-4141-aab7-25b869e54c49
콜백 파라미터 추가
void addCallbackParameter(String key, String value)
Adjust 대시보드에 콜백 URL을 등록하면 SDK가 이벤트를 기록할 때 ADK가 GET 요청을 콜백 URL로 보냅니다.
서버로 보낼 콜백 파라미터를 구성할 수 있습니다. 이벤트에 대한 파라미터 구성이 완료되면 SDK는 이를 콜백 URL에 추가합니다. 해당 정보를 사용하여, BI 시스템을 통해 사용자 인앱 행동을 분석할 수 있습니다.
String
키-값 인수와 함께 addCallbackParameter
메서드를 호출하여 이벤트에 콜백 파라미터를 추가합니다. 이 메서드를 여러 번 호출함으로써 여러 파라미터를 추가할 수 있습니다.
AdjustEvent myAdjustEvent = new AdjustEvent('abc123');//...adjustEvent.addCallbackParameter('key', 'value');//...Adjust.trackEvent(myAdjustEvent);
Adjust SDK는 이벤트를 측정하고 콜백 파라미터가 추가된 URL로 요청을 전송합니다. 예를 들어 URL https://www.mydomain.com/callback
을 등록한 경우 콜백은 다음과 같습니다.
https://www.mydomain.com/callback?key=value&foo=bar
CSV 업로드를 사용하는 경우, 반드시 CSV 정의에 파라미터를 추가하시기 바랍니다.
Adjust는 SDK에서 URL로 정보를 전송하는 데 사용할 수 있는 다양한 플레이스홀더를 지원합니다. 예를 들어, iOS의 경우 {idfa}
플레이스홀더, Android의 경우 {gps_adid}
플레이스홀더입니다. {publisher_parameter}
플레이스홀더는 단일 문자열의 모든 콜백 파라미터를 나타냅니다.
예
본 예시에서는 사용자가 버튼을 조작할 때마다 g3mfiw
라는 토큰으로 이벤트를 기록하는 방법을 보여줍니다. 다음 콜백 파라미터가 추가됩니다.
- 다양한
event_token
- 이벤트별로 생성되는
revenue_amount
콜백 URL의 결과는 다음과 같습니다.
http://www.mydomain.com/callback?event_token=g3mfiw&revenue_amount=0.05
import 'package:adjust_sdk/adjust_event.dart';import 'package:flutter/cupertino.dart';import 'package:flutter/material.dart';
class Util { static const String EVENT_TOKEN_CALLBACK = 'g3mfiw';
static Widget buildCupertinoButton(String text, Function action) { return new CupertinoButton( child: Text(text), color: CupertinoColors.activeBlue, padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 30.0), onPressed: action as void Function()?, ); }
static AdjustEvent buildCallbackEvent() { AdjustEvent event = new AdjustEvent(EVENT_TOKEN_CALLBACK); event.addCallbackParameter('event_token', EVENT_TOKEN_CALLBACK); event.addCallbackParameter('revenue_amount', '0.05'); return event; }
}
// main.dartimport 'util.dart';
// Send callback event button.Util.buildCupertinoButton('Send Callback Event', () => Adjust.trackEvent(Util.buildCallbackEvent())),const Padding(padding: const EdgeInsets.all(7.0))
Path: /eventClientSdk: flutter$FLUTTER_VERSIONParameters: callback_params {"event_token":"g3mfiw","revenue_amount":"0.05"} environment sandbox event_count 1 event_token g3mfiw
파트너 파라미터 추가
void addPartnerParameter(String key, String value)
파트너 파라미터를 추가하여 네트워크 파트너에게 추가 정보를 전송할 수 있습니다.
Adjust는 설정한 외부 파트너에게 파트너 파라미터를 전송합니다. 이러한 정보는 보다 세분화된 분석과 리타겟팅에 유용할 것입니다. 파트너에 대해 파라미터를 설정하고 활성화하면 Adjust 서버는 해당 파라미터를 포워드 합니다.
String
키-값 인수와 함께 addPartnerParameter
메서드를 호출하여 이벤트에 파트너 파라미터를 추가합니다. 이 메서드를 여러 번 호출함으로써 여러 파라미터를 추가할 수 있습니다.
AdjustEvent myAdjustEvent = new AdjustEvent('abc123');//...adjustEvent.addPartnerParameter('key', 'value');//...Adjust.trackEvent(myAdjustEvent);
예
본 예시에서는 사용자가 버튼을 조작할 때마다 g3mfiw
라는 토큰으로 이벤트를 기록하는 방법을 보여줍니다. 다음 파트너 파라미터가 추가됩니다.
- 관련 제품의
product_id
- 이벤트를 트리거한 사용자의
user_id
import 'package:adjust_sdk/adjust_event.dart';import 'package:flutter/cupertino.dart';import 'package:flutter/material.dart';
class Util { static const String EVENT_TOKEN_PARTNER = 'g3mfiw';
static Widget buildCupertinoButton(String text, Function action) { return new CupertinoButton( child: Text(text), color: CupertinoColors.activeBlue, padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 30.0), onPressed: action as void Function()?, ); }
static AdjustEvent buildPartnerEvent() { AdjustEvent event = new AdjustEvent(EVENT_TOKEN_PARTNER); event.addPartnerParameter('product_id', '29'); event.addPartnerParameter('user_id', '835'); return event; }
}
// main.dartimport 'util.dart';
// Send partner event button.Util.buildCupertinoButton('Send Partner Event', () => Adjust.trackEvent(Util.buildPartnerEvent())),const Padding(padding: const EdgeInsets.all(7.0))
Path: /eventClientSdk: flutter$FLUTTER_VERSIONParameters: partner_params {"product_id":"29","user_id":"835"} environment sandbox event_count 1 event_token g3mfiw
콜백 ID 추가
String? callbackId;
트래킹하려는 각 이벤트에 커스텀 문자열 ID를 추가할 수도 있습니다. Adjust 서버는 이벤트 콜백에서 이러한 식별자를 보고합니다. 이를 통해 성공적으로 트래킹된 이벤트 확인이 가능합니다.
ID를 이벤트 인스턴스의 callbackId
속성에 할당하여 식별자를 설정합니다.
AdjustEvent myAdjustEvent = new AdjustEvent('abc123');//...myAdjustEvent.callbackId = '{your_callback_id}';//...Adjust.trackEvent(myAdjustEvent);
예
본 예시에서는 사용자가 버튼을 조작할 때마다 g3mfiw
라는 토큰으로 이벤트를 기록하는 방법을 보여줍니다. callbackId
가 f2e728d8-271b-49ab-80ea-27830a215147
로 설정되었습니다.
import 'package:adjust_sdk/adjust_event.dart';import 'package:flutter/cupertino.dart';import 'package:flutter/material.dart';
class Util { static const String EVENT_TOKEN_SIMPLE = 'g3mfiw'; static const String CALLBACK_ID = "f2e728d8-271b-49ab-80ea-27830a215147"
static Widget buildCupertinoButton(String text, Function action) { return new CupertinoButton( child: Text(text), color: CupertinoColors.activeBlue, padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 30.0), onPressed: action as void Function()?, ); }
static AdjustEvent myAdjustEvent() { AdjustEvent event = new AdjustEvent(EVENT_TOKEN_SIMPLE); event.callbackId = CALLBACK_ID; return event;}
// main.dartimport 'util.dart';
Util.buildCupertinoButton('Send Callback Event', () => Adjust.trackEvent(Util.myAdjustEvent())),const Padding(padding: const EdgeInsets.all(7.0))
Path: /eventClientSdk: flutter$FLUTTER_VERSIONParameters: environment sandbox event_count 3 event_token g3mfiw callback_id f2e728d8-271b-49ab-80ea-27830a215147