google-tag-manager

Google tag manager rest api - trigger creation with filter returns an error


I am trying to create a new trigger by using google tag manager rest api and getting this error:

Unable to parse trigger data com.google.analytics.containertag.common.CtApiaryException: trigger.filter[0].parameter[1]: Filter's second argument must be string.

This is my payload:

const body = {
                accountId: googleTagManagerAccountId,
                containerId: containerId,
                workspaceId: workspaceId,
                name: `Bla bla PageViews Disabled JS - ${domainUrl}`,
                type: 'pageview',
                tagFiringOption: 'somePageViews',
                filter: [
                    {
                        parameter: [
                            {
                                type: 'template',
                                value: '{{ my Variable }}',
                                key: 'arg0',
                            },
                            {
                                type: 'boolean',
                                value: 'false',
                                key: 'arg1',
                            },
                        ],
                        type: 'contains',
                    },
                ],
            };

can someone explain me please what is wrong with my code?

Thanks


Solution

  • seems like you are using boolean and value you are passing is in string 'false' so either you need to update value or the parameter should be 'template'

    Option 1 : change type in filter

    filter: [
                    {
                        parameter: [
                            {
                                type: 'template',
                                value: '{{ Cheq Essentials Variable }}',
                                key: 'arg0',
                            },
                            {
                                type: 'template',
                                value: 'false',
                                key: 'arg1',
                            },
                        ],
                        type: 'contains',
                    },
                ],
    

    Option 2 : change value as boolean

      filter: [
                        {
                            parameter: [
                                {
                                    type: 'template',
                                    value: '{{ Cheq Essentials Variable }}',
                                    key: 'arg0',
                                },
                                {
                                    type: 'boolean',
                                    value: false,
                                    key: 'arg1',
                                },
                            ],
                            type: 'contains',
                        },
                    ],