Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Tag Manager throws "invalid macro" message
    text
    copied!<p>I've been trying out <code>Google Tag Manager</code> for mobile devices, specifically Android but I keep getting a message saying "invalid macro" when trying <code>getString(myKeyValue</code>) on a <code>Container</code>.</p> <p>Here's a part of my code in my MainActivity:</p> <pre><code>@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; } }); } </code></pre> <p>I've added these permissions in the manifest:</p> <pre><code>&lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt; &lt;uses-permission android:name="android.permission.INTERNET" /&gt; </code></pre> <p>I have the right Container_id because it shows the right version after refreshing it programmatically.</p> <p>And this is my assets/tagmanager/CONTAINER_ID.json file (of course with the right filename):</p> <pre><code>{ 'hello': 'hola', 'long' : '12345679' </code></pre> <p>}</p> <p>So after my container is initialized, I press a button that runs the code above, trying to get the values. But I get the error: "Invalid macro: hello" and "Invalid macro: long", also "Failed to convert '' to a number"</p> <p>This is a new service for mobile devices but can anybody help me with this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload