I'm trying to set up Google Tag Manager as per the Getting Started guide.
When adding a default container, the docs make it clear that using binary default container file (as opposed to JSON) is recommended.
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.
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 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)
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?
Using 'com.google.android.gms:play-services-analytics:7.0.0'