Google标签管理器REST API – 使用筛选器创建触发器返回错误。

huangapple go评论53阅读模式
英文:

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

问题

我正在尝试使用Google Tag Manager REST API创建一个新的触发器,并收到以下错误消息:

无法解析触发器数据 com.google.analytics.containertag.common.CtApiaryException: trigger.filter[0].parameter[1]: 过滤器的第二个参数必须为字符串。

这是我的负载:

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

有人可以解释一下我的代码有什么问题吗?

谢谢

英文:

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: '{{ Cheq Essentials Variable }}',
								key: 'arg0',
							},
							{
								type: 'boolean',
								value: 'false',
								key: 'arg1',
							},
						],
						type: 'contains',
					},
				],
			};

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

Thanks

答案1

得分: 0

看起来你正在使用布尔值,而你传递的值是字符串 'false',所以要么你需要更新值,要么参数应该是 'template'。

选项1:在过滤器中更改类型

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

选项2:将值更改为布尔值

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

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',
                    },
                ],

huangapple
  • 本文由 发表于 2023年7月27日 20:21:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/76779690.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定