adbrix 連携:Android Native
本マニュアルではadbrixを利用するために必要なSDK連携について案内します。
adbrixサービスの紹介と利用方法は、以下のマニュアルからご確認ください。
SDK ダウンロード&インストール
[SDKダウンロードセンター] から最新Android SDKパッケージをダウンロードします。
ダウンロードした .zip ファイルを解凍して IgawCommon~*.jar ファイルと IgawAdbrix~*.jar ファイルをAndroid Studio Projectにコピーし、gradleをアップデートします。
Manifest 設定
adbrixを利用するための内容を AndroidManifest.xml ファイルに追加します。
AppKey & HashKey 追加
adbrix 管理画面からアプリを登録し、発行したAppKeyとHashKeyを <application></application> タグに追加します。「アプリ登録方法」
<application>
...
<meta-data android:name="igaworks_app_key" android:value="input_your_app_key" />
<meta-data android:name="igaworks_hash_key" android:value="input_your_hash_key" />
...
</application>
Permission 追加
<manifest></manifest> タグに必須パーミッションを追加します。
<manifest>
...
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
...
</manifest>
Google Install Receiver 追加
<application></application> タグに IGAW インストールレシーバを追加します。
2つ以上のReceiverを追加する場合、[APPENDIX : カスタムインストールレシーバ登録] を参考して設定します。
<application>
...
<receiver android:name="com.igaworks.IgawReceiver" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER"/>
</intent-filter>
</receiver>
...
</application>
Caution!!! Install ReceiverはトラッキングURLを利用するために必ず設定してください。設定されない場合、正常に広告成果が計測できない場合があります。
Google Play Referrer 設定
Google Play Referrer 設定はadbrixの広告効果を計測する際に、不正トラフィックを防ぐために利用します。
※ 本機能は IgawCommon v4.5.4a から利用できます。
1) Android Studio
Google Play Referrer を利用するためには build-gradle に以下の dependencies を追加します。
dependencies {
...
compile 'com.android.installreferrer:installreferrer:1.0'
...
}
追加にて、プロジェクト build-gradle に以下のように repositories 内に google() 設定を追加します。
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
2) Eclipse などの他ツール
Eclipseなどの他ツールから Google Play Referrer を適用するために Installer ライブラリーを追加します。 ダウンロード
ライブラリーを追加した後、Androidmanifest.xml に以下の権限を追加します。
<uses-permission android:name="com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE"/>
プロガード設定
Android Studioの app/proguard-rules.pro ファイルに adbrix SDKに対する乱読化除外設定を追加します。
##---------------Begin: proguard configuration for Igaworks Common ----------
-keep class com.igaworks.** { *; }
-dontwarn com.igaworks.**
##---------------End: proguard configuration for Igaworks Common ----------
##---------------Begin: proguard configuration for Gson ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature
# For using GSON @Expose annotation
-keepattributes *Annotation*
# Gson specific classes
-keep class sun.misc.Unsafe { *; }
-keep class com.igaworks.gson.stream.** { *; }
# Application classes that will be serialized/deserialized over Gson
-keep class com.igaworks.adbrix.model.** { *; }
##---------------End: proguard configuration for Gson ----------
Caution!!! Eclipse プロジェクトの場合、Project/proguard-project.txt ファイルを修正します。
基本連携
セッション計測 : オート
<application
android:name="com.igaworks.IgawDefaultApplication"
... 省略 ...
>
</application>
自体 application クラスを利用している場合
<!-- AndroidManifest.xml -->
<application
android:name="PACKAGE_NAME.YourCustomApplication"
... 省略 ...
>
</application>
/* YourCustomApplication.java */
public class YourCustomApplication extends Application{
@Override
public void onCreate(){
super.onCreate();
IgawCommon.autoSessionTracking(YourCustomApplication.this);
// Application Classでは autoSessionTracking API 以外のどのadbrix APIも呼び出してはいけません。
}
}
セッション計測 : 手動
@Override
protected void onResume() {
super.onResume();
IgawCommon.startSession(MainActivity.this);
}
@Override
protected void onPause() {
super.onPause();
IgawCommon.endSession();
}
高度連携 : カスタムアクティビティ
FirstTimeExperience (FTE)
adbrix メニュー : Advanced analytics (高度分析) - 新規ユーザーセッション
目的 : firstTimeExperience APIは、アプリを初回起動したユーザーの離脱時点を確認するために利用します。
特徴 : アプリを初回起動した当日中のデータを提供します。(例:1月1日に流入したユーザーが1月2日にレベル10を達成した場合、レベル10は分析しません。)
//IgawAdbrix.firstTimeExperience(String userActivity);
IgawAdbrix.firstTimeExperience("loginComplete");
IgawAdbrix.firstTimeExperience("CharacterCreate");
IgawAdbrix.firstTimeExperience("TutorialComplete");
IgawAdbrix.firstTimeExperience("Level5Complete");
上記はゲームを想定した一例です。
userActivity パラメータでは空白以外の英字と数字を利用することをおすすめします。
Caution!!! ユーザーが当日に到達できるアクションまで連携してください。その後のアクションは分析で提供いたしません。
Purchase (In App Purchasing)
adbrixメニュー : 売上分析, Advanced Analytics (高度分析) - 初回課金, ROAS Reporting
目的 : 全ユーザーのアプリ内購入を日付別に分析、新規起動以外にも再インストール・再起動ユーザーの売上分析を提供します。
特徴 : adbrixで表示される売上は 'price x quantity' で提供します。
//商品の追加属性の定義
IgawCommerceProductAttrModel attrModel;
HashMap attrModel1 = new HashMap<>();
attrModel1.put("att1", "value1");
attrModel1.put("att2", "value2");
attrModel1.put("att3", "value3");
attrModel = new IgawCommerceProductAttrModel(attrModel1);
//商品購入 API 通知
IgawAdbrix.purchase(MainActivity.this,
"orerdID_1", //String orderID
IgawCommerceProductModel.create( //購入商品定義
"productID_1", //String productID
"ProudctName_1", //String productName
10000.00, //double price
0.00, //double discount
1, //int quantity
IgawCommerce.Currency.KR_KRW, //Currency
IgawCommerceProductCategoryModel.create("cat1"), //商品カテゴリー定義
attrModel), // Attr カテゴリー定義
IgawCommerce.IgawPaymentMethod.MobilePayment); //PaymentMethod
Retention (RET)
特徴 : 日付別のアクティビティ起動数と起動ユーザー数を提供、下位パラメータを対応します。
//IgawAdbrix.retention(String inAppActivity);
IgawAdbrix.retention("openStore");
IgawAdbrix.retention("stageClear");
IgawAdbrix.retention("purchaseItemWithVirtualCurrency");
IgawAdbrix.retention("inviteFriends");
Sub Activity 設定
retention APIはサブアクティビティとして下位パラメータを対応します。
adbrixメニュー : Advanced Analytics - In-app activities
目的 : ユーザーの特定行動について情報を追加可能です。(例:ログインーGoogle / LINE / Facebook)
//IgawAdbrix.retention(String inAppActivity, String subActivity);
IgawAdbrix.retention("login","kakaotalk");
高度連携 : コホート
SetCustomCohort
adbrixメニュー : adbrixメニューのフィルター
目的 :特定ユーザーグループでフィルターしてadbrixレポートを確認します。(性別、年齢、購入金額など)
特徴 : カスタムコホートは最大3つまで指定できます。
//IgawAdbrix.setCustomCohort(CohortVariable cohortFilter, String inAppActivity);
//カスタムコホートグループ 1 --> レベル達成情報
IgawAdbrix.setCustomCohort(CohortVariable.COHORT_1, "level_1");
IgawAdbrix.setCustomCohort(CohortVariable.COHORT_1, "level_5");
IgawAdbrix.setCustomCohort(CohortVariable.COHORT_1, "level_10");
//カスタムコホートグループ 2 --> 訪問回数情報
IgawAdbrix.setCustomCohort(CohortVariable.COHORT_2, "visit_10_times");
IgawAdbrix.setCustomCohort(CohortVariable.COHORT_2, "visit_20_times");
IgawAdbrix.setCustomCohort(CohortVariable.COHORT_2, "visit_30_times");
//カスタムコホートグループ 3 --> 課金金額区間情報
IgawAdbrix.setCustomCohort(CohortVariable.COHORT_3, "under_10000_won");
IgawAdbrix.setCustomCohort(CohortVariable.COHORT_3, "under_50000_won");
IgawAdbrix.setCustomCohort(CohortVariable.COHORT_3, "over_50000_won");
+ CohortVariableで事前に定義したフィルターは CohortVariable.COHORT_1~3 で、最大3つまで提供します。
+ adbrixメニューでコホートを提供しないメニューは以下になります。
- トラッキングURL - アナリティクス、ROAS Report
- App Analytics (基本分析) - リテンション、アクティブユーザー
- Advanced Analytics (高度分析) - 新規ユーザーセッション
- 売上分析 - 日別売上 (install date)
高度分析 : ユーザー分析
SetAge
ユーザーの年齢を 1~99 の定数で入力します。
IgawCommon.setAge(20);
SetGender
ユーザーの性別を IgawCommon.Gender で定義した設定値を利用して入力します。
IgawCommon.setGender(IgawCommon.Gender.MALE);
高度連携 : Commerce event
adbrixはEコマースアプリで発生する多彩な行動を分析するための追加連携機能を提供します。
O2O、越境EC、ホームショッピングなどのECアプリからのユーザーログイン、ディープリンク起動、カート追加、商品閲覧、購入などのユーザー行動を分析します。
詳細な内容は以下のリンクよりご確認ください。
adbrix Commerce event 連携 (準備中)
APPENDIX : カスタムインストールレシーバ登録
複数の ThirdParty ツールを利用する場合、Google Install Referrerを各 ThirdParty レシーバに渡されるよう処理する必要があります。
この場合、以下のように別途レシーバクラスを生成することをおすすめします。
<!-- AndroidManifest.xml -->
<receiver android:name="my_app_package.MultipleInstallReceiver" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER"/>
</intent-filter>
</receiver>
/* MultipleInstallReceiver.java */
public class MultipleInstallReceiver extends BroadcastReceiver {
@Override
public void onReceiver(Context context, Intent intent) {
//IGAW Google Install Receiver登録
IgawReceiver igawReceiver = new IgawReceiver();
igawReceiver.onReceive(context, intent);
//INSTALL_REFERRER を渡す他レシーバを登録します。
}
}
APPENDIX : ディープリンク計測
adbrixのディープリンク計測機能を利用するために、アプリにディープリンクを設定します。
ディープリンク設定
AndroidManifest.xml ファイルでディープリンクで起動するアクティビティの設定に、以下のように intent-filter を追加します。
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="YOUR_SCHEME_NAME_HERE" />
</intent-filter>
scheme 値が決まってない場合、adbrixのAppKeyを入力することも可能です。
adbrixのAppKeyが123456である場合、以下の例のように AndroidManifest.xml ファイルを修正します。
<activity android:label="@string/app_name" ...... >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="adbrix123456"/>
</intent-filter>
</activity>
Caution!!! deeplink schemeは小文字のみで構成することをおすすめします。[Android Developer Guide]
ディープリンクオープン計測
adbrixはトラッキングURLからのディープリンク起動計測を提供します。
トラッキングURLからのディープリンク起動計測のために、Android環境ではいくつか例外ケースに注意して設定する必要があります。
次のマニュアル中のチェックリストを参考して実装してください。
APPENDIX : ProcessKill 利用時の session 処理
adbrixの分析データは onPause()で呼び出される endSession api にてサーバーに転送します。
ですが、 ProcessKill などの強制終了方法を利用するアプリの場合、adbrixの分析データが流失される場合があります。
Androidのバックボタンでのイベントアクションに対して、以下のような処理を行い endSession APIが正常に呼び出されるように処理してください。
ProtectSessionTracking
processKill を処理する前に protectSessionTracking apiを呼び出してデータの流失を防ぎます。
public boolean onKeyDown(int keyCode, KeyEvent event){
switch(keyCode){
case KeyEvent.KEYCODE_BACK:
IgawCommon.protectSessionTracking(this);
new AlertDialog.Builder(this)
.setTitle("終了確認")
.setMessage("終了しますか?")
.setPositiveButton("はい", new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int which){
// 該当アプリのプロセスを強制Killする
android.os.Process.killProcess(android.os.Process.myPid());
}
}).setNegativeButton("いいえ", new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int which){
}
}).show();
}
return true;
}