Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Tag Manager throws "invalid macro" message

I've been trying out Google Tag Manager for mobile devices, specifically Android but I keep getting a message saying "invalid macro" when trying getString(myKeyValue) on a Container.

Here's a 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've added these permissions in the manifest:

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />

I have the right Container_id because it shows the right version after refreshing it programmatically.

And this is my assets/tagmanager/CONTAINER_ID.json file (of course with the right filename):

{
'hello': 'hola',
 'long' : '12345679'

}

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"

This is a new service for mobile devices but can anybody help me with this?

like image 620
dumazy Avatar asked Sep 18 '13 22:09

dumazy


1 Answers

I've found a problem for my case. I just downloaded a version from the web browser manager. The important thing is to add a rule that allows GTM to use this macro. Always comes in handy here.

Don't forget to publish the version of your container

like image 155
dumazy Avatar answered Oct 06 '22 01:10

dumazy