gpt4 book ai didi

android - Google 标签管理器不会将事件推送到 Android 上的数据层

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:13:38 25 4
gpt4 key购买 nike

我正尝试在我的 Android 应用程序中实现标签管理器,遵循 this guide ,但出于某种原因,我无法将事件推送到数据层。

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

TagManager tagManager = TagManager.getInstance(getApplicationContext());
TagManager.getInstance(getApplicationContext()).setVerboseLoggingEnabled(true);

PendingResult<ContainerHolder> pending = tagManager.loadContainerPreferFresh(GOOGLE_TAG_MANAGER_CONTAINER_ID, R.raw.gtm_default_container_v2);
pending.setResultCallback(new ResultCallback<ContainerHolder>() {
@Override
public void onResult(ContainerHolder containerHolder) {
TagManager.getInstance(getApplicationContext()).getDataLayer().push("event", "screenName");
// Using the "pushEvent" method doesn't work either
// TagManager.getInstance(getApplicationContext()).getDataLayer().pushEvent("screenName", DataLayer.mapOf());
}
}, 2, TimeUnit.SECONDS);
}

当我尝试运行我的应用程序时,我的所有日​​志都是这样

V/GoogleTagManager﹕ Attempting to load a container from the resource ID 2131099649 (com.example.cpe.gatestapp:raw/gtm_default_container_v2)
V/GoogleTagManager﹕ Deleted 0 expired items
W/GoogleTagManager﹕ Failed to extract the container from the resource file. Resource is a UTF-8 encoded string but doesn't contain a JSON container
V/GoogleTagManager﹕ The container was successfully loaded from the resource (using binary file)
E/GoogleTagManager﹕ Invalid macro: _gtm.loadEventEnabled
V/GoogleTagManager﹕ Attempting to load resource from disk
V/GoogleTagManager﹕ loadAfterDelay: containerId=GTM-XXXXXX delay=0
D/GoogleTagManager﹕ Setting previous container version: MQ$0
E/GoogleTagManager﹕ Invalid macro: _gtm.loadEventEnabled
V/GoogleTagManager﹕ The Disk resource was successfully read.
V/GoogleTagManager﹕ Start loading resource from network ...
V/GoogleTagManager﹕ Successfully loaded supplemented resource: zzi_p: "MQ$0"
V/GoogleTagManager﹕ No change for container: GTM-XXXXXX
V/GoogleTagManager﹕ loadAfterDelay: containerId=GTM-XXXXXX delay=43200000
D/GoogleTagManager﹕ Setting previous container version: MQ$0
E/GoogleTagManager﹕ Invalid macro: _gtm.loadEventEnabled
V/GoogleTagManager﹕ setting refresh time to current time: 1435818825632
V/GoogleTagManager﹕ Load resource from network finished.

我的 GA 和跟踪代码管理器帐户的屏幕截图:

tigger's

TagManager screen

Google analytics dump

最佳答案

在我想通之后,我的问题的答案非常简单。

因此,我创建了一个 Analytics Tracker,用于跟踪我的应用程序是否崩溃。我做了一个选择,如果我在 Debug模式下运行我的应用程序,也就是从 AndroidStudio 运行它,我的 Tracker 将进行“dryRun”。

所以我认为 TagManager 正在使用 Analytics 跟踪器发送所有事件。这就是为什么它有助于禁用我的 GoogleAnalytics 跟踪器上的 dryRun。

关于android - Google 标签管理器不会将事件推送到 Android 上的数据层,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31177444/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com