2

I am trying to implement the fairly new Android TagManager from Google. I can't seem to be able to load the default values.

I have created my default json file:

assets/tagmanager/GTM-xxx.json

Which looks like this:

{ 'eulaTextVersion': '1' }

I have also added this code to actually pull the default file if nothing is found on the server:

TagManager mTagManager = TagManager.getInstance(this);

        // The container is returned to containerFuture when available.
        ContainerOpener.openContainer(
            mTagManager,                            // TagManager instance.
            CONTAINER_ID,                           // Tag Manager Container ID.
            OpenType.PREFER_NON_DEFAULT,            // Prefer not to get the default container, but stale is OK.
            null,                                   // Time to wait for saved container to load (ms). Default is 2000ms.
            new ContainerOpener.Notifier() {        // Called when container loads.
              @Override
              public void containerAvailable(Container container) {
                // Handle assignment in callback to avoid blocking main thread.
                mContainer = container;
              }
            }
        );

int eulaTextVersion = (int) mContainer.getDouble("eulaTextVersion");

However, when I debug, my int eulaTextVersion is always zero, I can never get it to 1 like it should be from my default json. Could someone please help me out and show me where I am going wrong?

Thank you for the help.

4

2 回答 2

0

You shouldn't be using quotation for numerical values. Try the following instead

{ 'eulaTextVersion': 1 }
于 2014-01-17T05:34:23.457 回答
0

可能 Google 跟踪代码管理器已经为您下载了第一个版本。第一个版本可能是空的。只需使用包含“eulaTextVersion”和“发布”的“值”制作下一个版本。

如果您不知道如何在您的 Google Tag Manger 帐户上设置这些值,请查看:http: //youtu.be/Xe8W5w68BRg?t= 8m26s

于 2013-09-23T16:16:33.647 回答