I tested Google Tag Manager for mobile devices, in particular Android, but when I try to getString(myKeyValue on the Container page, I get a message with the message "invalid macro").
Here is part of my code in my MainActivity:
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); txtHello = (TextView)findViewById(R.id.txtHello); btn = (Button) findViewById(R.id.btn); btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { String hello = mContainer.getString("hello"); long l = mContainer.getLong("long"); txtHello.setText(hello + l); } }); tagManager = TagManager.getInstance(this); ContainerOpener.openContainer(tagManager, CONTAINER_ID, OpenType.PREFER_NON_DEFAULT, null, new ContainerOpener.Notifier() { @Override public void containerAvailable(Container container) { mContainer = container; } }); }
I added these permissions to the manifest:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.INTERNET" />
I have the correct Container_id because it shows the correct version after a software update.
And this is my assets / tagmanager / CONTAINER_ID.json file (of course, with the correct file name):
{ 'hello': 'hola', 'long' : '12345679'
}
So, after my container is initialized, I click on the button that launches the code above, trying to get the values. But I get an error: "Invalid macro: hello" and "Invalid macro: long", also "Failed to convert '' to number"
This is a new service for mobile devices, but can anyone help me with this?
android google-tag-manager
dumazy
source share