# マルチ - インスタンス
initInstance
を利用して、サブインスタンスを作成できます。
パラメータにはサブインスタンスの名称を入れて、呼び出すことができます。
// Create an instance named newInstance
te.initInstance("newInstance");
// set distinct_id for child instance and send the event of test_event
te.newInstance.identify("new_distinct_id");
te.newInstance.track("test_event");
デフォルトでは、サブインスタンスとメインインスタンスは同じ設定となりますが(appId
, serverUrl
など)、サブインスタンスはローカルキャッシュが起動しません。
サブインスタンスに独自の設定を行いたい場合は、初期設定時に設定しておいてください。異なるappId
が異なるプロジェクトへのデータ送信が可能になります。
// configuration parameters for child instance
var param = {
appId: "debug-appid",
serverUrl: "ANOTHER_SERVER_URL",
persistenceEnabled: true, // enable the local cache of the child instance
send_method: "image",
showLog: true
};
// init child instance
ta.initInstance("anotherInstance", param);
//upload data to the main instance
ta.track("Event");
//upload data to the child instance
ta.anotherInstance.track("Event");
メインインスアンスとサブインスタンスのID体系と共通イベントプロパティは共用しません。インスタンスごとで設定することが可能です。
//The main instance is the new user being invited and the child instance is the inviter
ta.login("invitee");
ta.anotherInstance.login("inviter");
//New user triggers invited event
ta.track("be_invited");
//Inviter trigger invite new user event
ta.anotherInstance.track("invite_new_user");
← プリセットプロパティ リリース履歴 →