Send feedback
Advanced Android Tag Manager configuration
Stay organized with collections
Save and categorize content based on your preferences.
To extend the functionality of Google Tag Manager, you can add Function Call
variables and Function Call tags. Function Call variables let you capture the
values returned by calls to pre-registered functions. Function Call tags let you
execute pre-registered functions (e.g., to trigger hits for additional
measurement and remarketing tools that are not currently supported with tag
templates in Tag Manager).
To add a custom tag or custom variable with a Function Call:
Implement a class that extends
com.google.android.gms.tagmanager.CustomTagProvider
or
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 );
}
}
}
If you use ProGuard , make sure that the class names and methods are not
obfuscated. Use the Keep annotation to specify this.
In Google Tag Manager's web interface, use the fully qualified class name
to set up tags and variables:
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2021-08-13 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
Need to tell us more?
{"lastModified": "Last updated 2021-08-13 UTC."}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2021-08-13 UTC."]]