Android タグ マネージャーの詳細設定
関数呼び出し変数と関数呼び出しタグを追加して、Google タグ マネージャーの機能を拡張することができます。関数呼び出し変数を使用すると、事前登録された関数の呼び出しによって返された値を取得できます。関数呼び出しタグを使用すると、事前に登録された関数を呼び出して、たとえば、タグ マネージャーのタグ テンプレートで現在サポートされていない追加の測定ツールやリマーケティング ツールのヒットをトリガーすることができます。
関数呼び出しでカスタムタグまたはカスタム変数を追加するには:
com.google.android.gms.tagmanager.CustomTagProvider
または com.google.android.gms.tagmanager.CustomVariableProvider
を拡張するクラスを実装します。
import android.support.annotation.Keep;
import java.util.Map;
@Keep
public class HighScoreProvider implements com.google.android.gms.tagmanager.CustomVariableProvider {
@Override
public String getValue(Map<String, Object> map) {
synchronized (HighScoreProvider.class) {
return ((Long)sHighScore).toString();
}
}
private static long sHighScore = 0;
public static void recordScore(long score) {
synchronized (HighScoreProvider.class) {
sHighScore = Math.max(score, sHighScore);
}
}
}
ProGuard を使用する場合は、クラス名とメソッドが難読化されないようにします。Keep オプションを使用すると、難読化の対象から外すことができます。
Google タグ マネージャーの管理画面で、完全修飾クラス名を使用してタグと変数を設定します。

特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2024-11-08 UTC。
[null,null,["最終更新日 2024-11-08 UTC。"],[[["Function Call variables enable capturing values from pre-registered function calls, extending Google Tag Manager's capabilities."],["Function Call tags allow execution of pre-registered functions, such as triggering hits for unsupported measurement tools."],["Custom tags and variables can be added by implementing a class extending `CustomTagProvider` or `CustomVariableProvider`."],["ProGuard users should prevent obfuscation of custom class names and methods using the Keep annotation."],["Within the Google Tag Manager interface, use the fully qualified class name to configure the custom tags and variables."]]],["Function Call variables and tags extend Google Tag Manager's functionality. Function Call variables capture values from pre-registered function calls, while Function Call tags execute pre-registered functions. To add custom tags/variables, implement a class extending `CustomTagProvider` or `CustomVariableProvider`. Use the `@Keep` annotation to prevent obfuscation with ProGuard. Finally, configure tags and variables in Google Tag Manager's web interface using the fully qualified class name.\n"]]