标签管理:如何加载二进制默认容器? [英] Tag Manager: How to load binary default container?

查看:415
本文介绍了标签管理:如何加载二进制默认容器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图建立谷歌代码管理工具为每入门指南。

I'm trying to set up Google Tag Manager as per the Getting Started guide.

在添加默认容器,该文档使明确指出,使用默认容器文件(而不是JSON)建议。

When adding a default container, the docs make it clear that using binary default container file (as opposed to JSON) is recommended.

虽然使用二进制文件建议,如果你的容器不
  不包含规则或标签,你可以选择使用一个简单的JSON文件
  来代替。

Although using the binary file is recommended, if your container does not contain rules or tags, you may choose to use a simple JSON file instead.

我已经下载并在 RES /原料添加二进制默认容器。但是,初始化代码管理与 loadContainer preferNonDefault()似乎失败。

I've downloaded and added the binary default container under res/raw. But initialising Tag Manager with loadContainerPreferNonDefault() seems to fail.

PendingResult<ContainerHolder> pending =
    tagManager.loadContainerPreferNonDefault(CONTAINER_ID,
    R.raw.gtm_default_container);

我得到这个错误日志中:

I get this error in logs:

 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

TagManager的javadoc (本例在最高层)暗示,你可以传递一个布尔值参数,指示资源是否是JSON或二进制:

TagManager javadocs (the example at the very top) hint that you can pass a boolean param to indicate whether the resource is JSON or binary:

PendingResult pending = tagManager.loadContainerPreferNonDefault(
         myContainerId,    // container ID of the form "GTM-XXXX"
         R.raw.GTM-XXXX,   // the resource ID of the default container
         true);            // the default container is in JSON format (as opposed to binary)

的是,有没有这样的参数在<一个href=\"https://developer.android.com/reference/com/google/android/gms/tagmanager/TagManager.html#loadContainer$p$pferNonDefault(java.lang.String,%20int)\"相对=nofollow> loadContainer preferNonDefault()
您可以选择通过一个处理程序,但没有布尔值。 Dumbfoundingly的TagManager这里的javadoc冲突本身。

Thing is, there's no such parameter in loadContainerPreferNonDefault()! You can optionally pass a Handler but no boolean. Dumbfoundingly, the TagManager javadoc conflicts itself here.

所以无论如何,它甚至有可能做入门指南建议是什么,以及使用的二进制的默认容器?

So anyway, is it even possible to do what the Getting Started guide recommends, and use a binary default container?

使用'com.google.android.gms:发挥服务 - 分析:7.0.0

推荐答案

对不起,我迟到的答案。有一些挣扎与标签管理,并设法解决我的。希望这有助于:

Sorry for the late answer. Had some struggles with Tag Manager and managed to solve mine. Hope this helps:

是,也可以使用二进制默认容器。该文档与标签管理的previous版本冲突。我相信这是相互矛盾与V3。 (当前版本为写这个答案是V4)。

Yes, it is possible to use a binary default container. The documentation is conflicting with a previous version of Tag Manager. I believe it's conflicting with v3. (The current version as of writing this answer is v4).

要加载你需要使用不同的方法二进制容器。

To load the binary container you need to use a different method.

您需要使用 TagManager.loadContainerDefaultOnly()此方法用于测试目的专门供,这样你可以,如果容器发送匹配的,即使没有发布的容器测试。

You need to use TagManager.loadContainerDefaultOnly() this method is intended specifically for testing purposes so that you could test if a container is sending hits even with no container published.

在另一方面 TagManager.loadContainer preferNonDefault()将加载它的二进制容器,然后检查网络为当前发布的版本。如果发现被发布,将使用该版本无论你有什么二进制文件容器中的版本。例如:

On the other hand TagManager.loadContainerPreferNonDefault() will load it's binary container and then check the network for a version that is currently published. If it finds a version that is published it will use that version no matter what binary container you have. Example:

您添加二进制容器version15。然而,你已经version14出版。此方法将默认为14,因为该版本发布。

You add binary container version15. However you have version14 published. This method will default to 14, since that version is published.

如果你想测试版本15,你将不得不使用 TagManager.loadContainerDefaultOnly()

If you wanted to test version 15 you would have to use TagManager.loadContainerDefaultOnly().

这篇关于标签管理:如何加载二进制默认容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆