고급 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 태그 관리자의 웹 인터페이스에서 정규화된 클래스 이름을
사용하여 태그 및 변수를 설정합니다.

달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2024-11-08(UTC)
[null,null,["최종 업데이트: 2024-11-08(UTC)"],[[["\u003cp\u003eFunction Call variables enable capturing values from pre-registered function calls, extending Google Tag Manager's capabilities.\u003c/p\u003e\n"],["\u003cp\u003eFunction Call tags allow execution of pre-registered functions, such as triggering hits for unsupported measurement tools.\u003c/p\u003e\n"],["\u003cp\u003eCustom tags and variables can be added by implementing a class extending \u003ccode\u003eCustomTagProvider\u003c/code\u003e or \u003ccode\u003eCustomVariableProvider\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eProGuard users should prevent obfuscation of custom class names and methods using the Keep annotation.\u003c/p\u003e\n"],["\u003cp\u003eWithin the Google Tag Manager interface, use the fully qualified class name to configure the custom tags and variables.\u003c/p\u003e\n"]]],["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"],null,["# Advanced Android Tag Manager configuration\n\nTo extend the functionality of Google Tag Manager, you can add Function Call\nvariables and Function Call tags. Function Call variables let you capture the\nvalues returned by calls to pre-registered functions. Function Call tags let you\nexecute pre-registered functions (e.g., to trigger hits for additional\nmeasurement and remarketing tools that are not currently supported with tag\ntemplates in Tag Manager).\n\nAdd custom tags and variables\n-----------------------------\n\nTo add a custom tag or custom variable with a Function Call:\n\n1. Implement a class that extends\n `com.google.android.gms.tagmanager.CustomTagProvider` or\n `com.google.android.gms.tagmanager.CustomVariableProvider`:\n\n import android.support.annotation.Keep;\n import java.util.Map;\n\n @Keep\n public class HighScoreProvider implements com.google.android.gms.tagmanager.CustomVariableProvider {\n @Override\n public String getValue(Map\u003cString, Object\u003e map) {\n synchronized (HighScoreProvider.class) {\n return ((Long)sHighScore).toString();\n }\n }\n\n private static long sHighScore = 0;\n public static void recordScore(long score) {\n synchronized (HighScoreProvider.class) {\n sHighScore = Math.max(score, sHighScore);\n }\n }\n }\n\n2. If you use [ProGuard](https://developer.android.com/tools/help/proguard.html), make sure that the class names and methods are not\n obfuscated. Use the Keep annotation to specify this.\n\n3. In Google Tag Manager's web interface, use the fully qualified class name\n to set up tags and variables:"]]