Google Tag Manager displays "Invalid Macro"

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?

+7
android google-tag-manager
source share
3 answers

I found a problem for my business. I just downloaded the version from the web browser manager. It is important to add a rule that allows GTM to use this macro. Always come in handy here.

Remember to post your container version

+6
source share

For people who don’t get what dumazy refer to

enable user variables

you also need to enable it using Always or any other relevant rules.

+3
source share

In your json you use quotas of '123456' to determine the long, you should not:

 { 'string': 'hola', 'long': 123456, 'double': 123.123 } 

If you have additional problems, look: Android TagManager does not get the default value

0
source share

All Articles