TealiumのXamarin用クラスとメソッドのリファレンスガイド。
クラス: Tealium
Tealium XamarinライブラリのTealiumクラスのメソッドと定数。
AddRemoteCommand()
リモートコマンドマネージャーにリモートコマンドを追加します。
void AddRemoteCommand(IRemoteCommand remoteCommand);
| パラメータ | 型 | 説明 |
|---|---|---|
remoteCommand | IRemoteCommand | IRemoteCommandインターフェースの実装で、必要なリモートコマンドのプロパティを提供します。 |
例:
public class MyRemoteCommand : IRemoteCommand
{
public string CommandId => "my_remote_command";
public string Description => "description of my remote command";
public string Path => null;
public string Url => null;
public void Dispose()
{
//
}
public void HandleResponse(IRemoteCommandResponse response)
{
var str = response.Payload.GetValueForKey<String>("key");
if (str == "")
{
// etc
}
}
}
tealium.AddRemoteCommand(new MyRemoteCommand());
AddToDataLayer()
指定された有効期限で永続データ保存にデータを追加します。
void AddToDataLayer(IDictionary<string, object> data, Expiry expiry);
| パラメータ | 型 | 説明 |
|---|---|---|
data | IDictionary<string, object> | 文字列のキーとプリミティブまたはコレクションの値を持つキー値ペアのIDictionary |
expiry | Expiry | データを保持する時間の長さ |
tealium.AddToDataLayer(new Dictionary<string, object> {
{ "user_language", lang }
}, Expiry.Forever);
ClearStoredVisitorIds()
保存されている訪問IDをクリアし、新しいIDを生成します。主に法的コンプライアンスのために使用されます。
訪問IDは、データレイヤーにvisitorIdentityKey構成が含まれている場合に基づいて引き続き保存されます。
tealium.ClearStoredVisitorIds();
保存をクリアした後、現在のアイデンティティと共に新しくリセットされたvisitorIdを保存しないようにするためには、アイデンティティキーを事前にデータレイヤーから削除する必要があります(RemoveFromDataLayer()を参照)。
ConsentCategory
同意カテゴリの値。GetConsentCategoriesおよびSetConsentCategoriesで使用します。
同意カテゴリは以下の通りです:
ConsentManager.ConsentCategory.AnalyticsConsentManager.ConsentCategory.AffiliatesConsentManager.ConsentCategory.BigDataConsentManager.ConsentCategory.CdpConsentManager.ConsentCategory.CookieMatchConsentManager.ConsentCategory.CrmConsentManager.ConsentCategory.DisplayAdsConsentManager.ConsentCategory.EmailConsentManager.ConsentCategory.EngagementConsentManager.ConsentCategory.MiscConsentManager.ConsentCategory.MobileConsentManager.ConsentCategory.MonitoringConsentManager.ConsentCategory.PersonalizationConsentManager.ConsentCategory.SearchConsentManager.ConsentCategory.Social
ConsentStatus
同意ステータスの値。SetConsentStatus()で使用します。
| 値 | 説明 |
|---|---|
ConsentManager.ConsentStatus.Consented | 同意済み |
ConsentManager.ConsentStatus.NotConsented | 同意していない |
ConsentManager.ConsentStatus.Unknown | 不明 |
Environment
環境は、デフォルトの三つの環境(Dev, QA, Prod)または公開する任意のカスタム環境のいずれかです。
| 値 | 説明 |
|---|---|
Environment.dev | 開発 |
Environment.qa | QA/UAT |
Environment.prod | 本番 |
Expiry
永続的または揮発性データの有効期限を定義します。AddToDataLayer()で使用します。
| 値 | 説明 |
|---|---|
Expiry.Session | 現在のアクティブセッションの長さ。 |
Expiry.UntilRestart | 次の再起動までの時間の長さ。 |
Expiry.Forever | アプリが削除されるまでの時間の長さ。 |
GetFromDataLayer()
永続データレイヤーで指定されたキーの値を取得します。
object? GetFromDataLayer(string key);
| パラメータ | 型 | 説明 |
|---|---|---|
key | String | データレイヤーから取得するキー |
string myString = (string)tealium.GetFromDataLayer("user_language");
GetConsentCategories()
ユーザーが同意したカテゴリのリストを取得します。
List<ConsentCategory>? GetConsentCategories();
例:
tealium.GetConsentCategories().ForEach((c) =>
{
if (c == ConsentManager.ConsentCategory.Analytics)
{
// Analyticsに同意
}
});
GetConsentStatus()
ユーザーの同意の現在の状態を取得します。ConsentStatus値を返します。
ConsentStatus GetConsentStatus();
例:
switch (tealium.GetConsentStatus()) {
case ConsentManager.ConsentStatus.Unknown:
break;
case ConsentManager.ConsentStatus.Consented:
break;
case ConsentManager.ConsentStatus.NotConsented:
break;
}
GetVisitorId()
ユーザーの訪問IDを取得し、コールバック関数の形で返します。
string? visitorId = tealium.GetVisitorId();
JoinTrace()
指定されたIDでトレースに参加します。Tealium Customer Data HubのTrace機能について詳しくはこちら。
tealium.JoinTrace(id);
| パラメータ | 型 | 説明 | 例 |
|---|---|---|---|
id | String | トレースID | abc123xy |
LeaveTrace()
トレースはアプリセッションの間アクティブのままであり、leaveTrace()メソッドが呼ばれると、以前に参加したトレースを離れ、訪問セッションが終了します。
tealium.LeaveTrace();
RemoveFromDataLayer()
以前にAddToDataLayer()を使用して構成された永続データを削除します。
void RemoveFromDataLayer(ICollection<string> keys);
| パラメータ | 型 | 説明 |
|---|---|---|
keys | ICollection<String> | キー名のコレクション |
tealium.RemoveFromDataLayer(new string[] { "key1", "key2" });
RemoveRemoteCommand()
リモートコマンドマネージャーからリモートコマンドを削除します。
void RemoveRemoteCommand(string id);
| パラメータ | 型 | 説明 |
|---|---|---|
id | String | 削除するコマンドIDの名前 |
tealium.RemoveRemoteCommand("firebase");
ResetVisitorId()
訪問IDをリセットし、新しいIDを生成します。
tealium.ResetVisitorId();
SetConsentCategories()
ユーザーが同意したカテゴリのリストを構成します。ConsentCategoryと共に使用します。
void SetConsentCategories(List<ConsentCategory> categories);
| パラメータ | 型 | 説明 |
|---|---|---|
categories | List<ConsentCategory> | ユーザー同意カテゴリのリスト。 |
tealium.SetConsentCategories(new List<ConsentManager.ConsentCategory>()
{
ConsentManager.ConsentCategory.DisplayAds,
ConsentManager.ConsentCategory.Analytics
});
SetConsentExpiryListener()
同意構成の有効期限が切れたときに実行するコールバックメソッドを構成します。
void SetConsentExpiryListener(Action callback);
| パラメータ | 型 | 説明 |
|---|---|---|
callback | Action | 同意が期限切れになったときに実行するコード。 |
tealium.SetConsentExpiryListener(() =>
{
System.Diagnostics.Debug.WriteLine("Consent Expired");
});
SetConsentStatus()
ユーザーの同意状態を構成します。デフォルト値は構成されるまで.Unknownです。
void SetConsentStatus(ConsentStatus status);
| パラメータ | 型 | 説明 |
|---|---|---|
status | ConsentStatus | ユーザーの同意状態。ConsentManager.ConsentStatusを参照。 |
tealium.SetConsentStatus(ConsentManager.ConsentStatus.NotConsented);
SetVisitorServiceListener()
訪問プロファイルが更新されたときに実行するコールバック関数を構成します。コールバック応答で更新されたVisitorProfileが提供されます。visitorServiceEnabledがtrueに構成されている場合に使用します。
Tealium AudienceStreamのライセンスを持っていて、モバイルアプリケーションで訪問プロファイルを使用してユーザーエクスペリエンスを向上させたい場合にこの機能を使用します。
void SetVisitorServiceListener(Action callback);
| パラメータ | 型 | 説明 |
|---|---|---|
callback | Action | 訪問プロファイルが取得されたときに実行するコード。 |
tealium.SetVisitorServiceListener((visitorProfile) =>
{
System.Diagnostics.Debug.WriteLine("Visitor Updated");
System.Diagnostics.Debug.WriteLine($"Visitor: {visitorProfile}");
});
TerminateIntance()
Tealiumライブラリを無効にし、すべてのモジュール参照を削除します。
tealium.TerminateIntance();
Track()
TealiumEventまたはTealiumViewディスパッチでイベントを追跡します。
tealium.Track(tealEvent);
| パラメータ | 型 | 説明 |
|---|---|---|
tealEvent | string | イベント名。tealium_event属性として渡され、オプショナルなイベントデータオブジェクトがあります。 |
イベントを追跡するには、TealiumEventオブジェクトを作成し、track()メソッドに渡します:
tealium.Track(new TealiumEvent("cart_add", new Dictionary<string, object> {
{ "customer_id", "abc123" },
{ "product_id", ["PROD123", "PROD456"] },
{ "product_price", [4.00, 6.00] }
}));
クラス: TealiumConfig
以下は、TealiumConfig クラスのプロパティをまとめたものです。
| パラメータ | 型 | 説明 | 例 |
|---|---|---|---|
account | String | (必須) Tealiumアカウント名 | "companyXYZ" |
profile | String | (必須) Tealiumプロファイル名 | "main" |
environment | Environment | (必須) Tealium環境名 | Environment.dev |
dataSource | String | CDHデータソースキー | "abc123" |
collectors | Collectors[] | (必須) Tealiumライブラリを初期化するためのCollectorsのリストを構成 | [Collectors.AppData] |
dispatchers | Dispatchers[] | (必須) Tealiumライブラリを初期化するためのDispatchersのリストを構成 | [Dispatchers.Collect] |
customVisitorId | String | カスタム訪問IDを構成 | "ALK2398LSDKJ3289SLKJ3298SLKJ3" |
memoryReportingEnabled | Boolean | デバイスデータモジュールでのメモリレポートを有効または無効にする(デフォルト: 無効)。 | true |
overrideCollectDomain | String | Tealium Collect URLのドメインを上書き。ファーストパーティドメインで使用。 | "your-domain.com" |
overrideCollectURL | String | Tealium Collect URLを上書きして、データを別のエンドポイントに送信。イベントバッチ機能を使用する場合は、overrideCollectBatchURLプロパティも上書き。 | "https://custom-domain.com/event" |
overrideCollectBatchURL | String | Tealium CollectバッチURLを上書きして、データを別のエンドポイントに送信。 | "https://custom-domain.com/batch-event" |
overrideLibrarySettingsURL | String | 公開構成URLを上書き。 | "https://custom-domain.com/mobile.html" |
overrideTagManagementURL | String | タグ管理モジュールで使用されるデフォルトURLを上書き。TealiumのJavaScriptファイルを自己ホスティングする場合に必要。 | "https://custom-domain.com/path/env/utag.js" |
deepLinkTrackingEnabled | Boolean | 標準ディープリンクの自動追跡を有効または無効にする。例えば、Facebookや他のソースからのアプリへのリンク、QRトレースも含む(デフォルト: 有効)。 | false |
qrTraceEnabled | Boolean | QRトレースを有効または無効にする(デフォルト: 有効)。 | false |
loglevel | LogLevel | ログレベルプロパティを構成し、ログに記録される情報の量を制御する(デフォルト: サイレント)。 | LogLevel.dev |
consentExpiry | ConsentExpiry | ユーザーの同意構成の有効期限を構成する。(ポリシーに依存するデフォルト値) | ConsentExpiry(90, TimeUnit.days) |
consentLoggingEnabled | Boolean | 同意ログ記録機能を有効にする。これにより、すべての同意ステータスの変更が監査目的でTealium Customer Data Hubに送信される(デフォルト: 有効)。 | true |
consentPolicy | ConsentPolicy | 同意ポリシーを構成する。例えば、CCPAまたはGDPR。このプロパティが構成されている場合のみ、Consent Managerが有効になる。 | ConsentPolicy.gdpr |
lifecycleAutotrackingEnabled | Boolean | ライフサイクル自動追跡を有効または無効にする(デフォルト: 有効)。 | false |
useRemoteLibrarySettings | Boolean | モバイル公開構成を有効または無効にする(デフォルト: 有効)。Tealium iQタグ管理でモバイル公開構成を構成するか、この機能を無効にする。 | false |
visitorServiceEnabled | Boolean | データレイヤーエンリッチメントAPIを使用して訪問プロファイルの自動取得を有効または無効にする(デフォルト: 無効)。 | true |
remoteCommands | RemoteCommand[] | インスタンスが準備完了時に追加するRemoteCommandオブジェクトのリストを構成 | [{ id: "hello-world", callback: (payload) => { console.log("hello-world: " + JSON.stringify(payload)); } }] |
overrideConsentCategoriesKey | String | 同意カテゴリイベント属性の名前を上書き。サーバーサイドの同意の自動適用を無効にするために使用。サーバーサイド同意管理の自動適用を無効にするについて詳しく学ぶ。(デフォルト: consent_categories) | consent_categories_granted |
visitorIdentityKey | String | 訪問の切り替えをサポートし、アプリの複数のユーザーを識別する共有キーを指定するために使用。 | user_profile_id |
Collectors
Collectorsは、デバイスから追加情報を収集し、Tealium Customer Data Hubに送信される前にデータレイヤーに追加するモジュールです。いくつかのコレクターはコアライブラリに含まれており、他のコレクターは別のモジュールとしてオプションでインストールされます。
以下の表は、利用可能なコレクターをリストしています。デフォルトのコレクターはコレクター名の隣に * が付けられています。
| コレクター名 | TealiumConfig参照 |
|---|---|
AppData* | Collectors.AppData |
Connectivity* | Collectors.Connectivity |
Device | Collectors.Device |
Lifecycle | Collectors.Lifecycle |
これらのモジュールは、TealiumConfigで構成されたCollectorsプロパティを使用して有効または無効にされます。
TealiumConfig tealConfig = new TealiumConfig(
// ...
new List<Collectors> {
Collectors.LifeCycle, Collectors.Device
}
// ...
);
ConsentExpiry
TealiumConfigオブジェクト上で同意構成の有効期限を構成します。
| パラメータ | 型 | 説明 |
|---|---|---|
time | Number | 有効期限までの時間。 |
unit | TimeUnit | 有効期限までの時間単位。TimeUnit.Minutes, TimeUnit.Hours, TimeUnit.Days, TimeUnit.Monthsのいずれか |
TealiumConfig config = new TealiumConfig(
//...
consentExpiry = new TimeUnit(90, TimeUnit.Days)),
//...
);
ConsentPolicy
TealiumConfigオブジェクトで使用する同意ポリシーを構成します。同意ポリシーが構成されていない場合、同意マネージャーは無効です。
TealiumConfig config = new TealiumConfig(
//...
consentPolicy = ConsentPolicy.GDPR,
//...
);
同意値:
ConsentPolicy.GDPRConsentPolicy.CCPA
Dispatchers
Dispatchersは、データをTealiumエンドポイントに送信するモジュールです。これらはTealiumConfigオブジェクトに構成されます。
TealiumConfig tealConfig = new TealiumConfig(
// ...
new List<Dispatchers> {
Dispatchers.Collect, Dispatchers.RemoteCommands
}
// ...
);
利用可能なディスパッチャーは以下の通りです:
Dispatchers.CollectDispatchers.RemoteCommandsDispatchers.TagManagement
少なくとも1つのディスパッチャーが必要です。
LogLevel
ログレベルプロパティを構成し、ログに記録される情報の量を制御します。以下の値のいずれかに構成します:
| 値 | 説明 |
|---|---|
LogLevel.dev | アプリケーションの進行を強調する情報イベント |
LogLevel.qa | アプリケーションのデバッグに使用されるデバッグレベルのイベント |
LogLevel.prod | クリティカルエラーや障害などのエラーイベント |
LogLevel.silent | ログなし(デフォルト) |
IRemoteCommand
リモートコマンドを定義するインターフェースです。
| 値 | 説明 |
|---|---|
CommandId | リモートコマンドの一意の識別子名 |
Description | (オプション)リモートコマンドの一意の識別子名 |
Path | (オプション)マッピングに使用するローカルファイル |
Url | (オプション)マッピングに使用するリモートファイル |
IVisitorProfile
(TealiumConfig.visitorServiceEnabledで使用します。)
訪問プロファイルオブジェクトには、訪問サービスから返される訪問属性が含まれています。currentVisitプロパティには現在の訪問に関連する属性が含まれています。サブスクリプトを使用してIDで各属性値にアクセスします。属性が存在しない場合は、nullが返されます。
| パラメーター | プロパティ | 値 |
|---|---|---|
ArraysOfBooleans | IDictionary<string, IList<bool>> | id: "5129", value: [true,false,true,true] |
ArraysOfNumbers | IDictionary<string, IList<double>> | id: "57", value: [4.82125, 16.8, 0.5714285714285714] |
ArraysOfStrings | IDictionary<string, IList<string>> | id: "5213", value: ["green shirts", "green shirts", "blue shirts"] |
Audiences | IDictionary<string, string> | id: "tealiummobile_demo_103", value: "iOS Users" |
Badges | IDictionary<string, bool> | id: "2815", value: true |
Booleans | IDictionary<string, bool> | id: "4868", value: true |
CurrentVisit | ICurrentVisit | |
Dates | IDictionary<string, long> | id: "22", value: 1567120112000 |
Numbers | IDictionary<string, double> | id: "5728", value: 4.82125 |
SetOfStrings | IDictionary<string, ISet<string>> | id: "5211", value: ["green shirts", "red shirts", "blue shirts"] |
Strings | IDictionary<string, string> | id: "5380", value: "green shirts" |
Tallies | IDictionary<string, IDictionary<string, double>> | "57": [["category 1": 2.0], "category 2": 1.0]] |
ICurrentVisit
現在の訪問に関連する属性を含むオブジェクトです。
| パラメーター | プロパティ | 値 |
|---|---|---|
ArraysOfBooleans | IDictionary<string, IList<bool>> | id: "5129", value: [true,false,true,true] |
ArraysOfNumbers | IDictionary<string, IList<double>> | id: "57", value: [4.82125, 16.8, 0.5714285714285714] |
ArraysOfStrings | IDictionary<string, IList<string>> | id: "5213", value: ["green shirts", "green shirts", "blue shirts"] |
Booleans | IDictionary<string, bool> | id: "4868", value: true |
Dates | IDictionary<string, long> | id: "22", value: 1567120112000 |
Numbers | IDictionary<string, double> | id: "5728", value: 4.82125 |
SetOfStrings | IDictionary<string, ISet<string>> | id: "5211", value: ["green shirts", "red shirts", "blue shirts"] |
Strings | IDictionary<string, string> | id: "5380", value: "green shirts" |
Tallies | IDictionary<string, IDictionary<string, double>> | "57": [["category 1": 2.0], "category 2": 1.0]] |
TotalEventCount | int | 42 |
CreatedAt | long | 1638236024 |
インターフェース: TealiumDispatch
追跡するディスパッチのタイプを定義するインターフェースです。以下のクラスが TealiumDispatch を実装しています:
クラス: TealiumEvent
ユーザーの画面とのインタラクションまたは画面表示を追跡するには、TealiumEvent(tealiumEvent, dataLayer)のインスタンスをTrack()メソッドに渡します。TealiumEventは、追跡コールにtealium_eventとして表示されるイベント名と、オプションのデータ辞書で構成されています。
tealium.Track(new TealiumEvent("tealiumEvent", new Dictionary<string, object> {
eventData
}));
| パラメーター | タイプ | 説明 |
|---|---|---|
tealiumEvent | string | tealium_event属性として渡されるイベント名 |
eventData | Dictionary<string, object> | (オプション)イベントに送信するキーと値の形式のデータ |
例:
tealium.Track(new TealiumEvent("cart_add", new Dictionary<string, object> {
{ "customer_id", "abc123" },
{ "product_id", ["PROD123", "PROD456"] },
{ "product_price", [4.00, 6.00] }
}));
クラス: TealiumView
画面表示を追跡するには、TealiumView(tealiumEvent, dataLayer)のインスタンスをTrack()メソッドに渡します。TealiumViewは、追跡コールにtealium_eventとして表示されるビュー名と、オプションのデータ辞書で構成されています。
tealium.Track(new TealiumView("tealiumEvent", new Dictionary<string, object> {
eventData
}));
| パラメーター | タイプ | 説明 |
|---|---|---|
tealiumEvent | string | tealium_event属性として渡されるイベント名 |
eventData | Dictionary<string, object> | (オプション)イベントに送信するキーと値の形式のデータ |
例:
tealium.Track(new TealiumView("purchase", new Dictionary<string, object> {
{ "customer_id", "abc123" },
{ "order_total", 10.00 },
{ "product_id", ["PROD123", "PROD456"] },
{ "order_id", "0123456789" }
}));
最終更新日 :: 2025年September月4日