Matthew Michaud
Matthew Michaud

Reputation: 135

How to use built-in triggers with Google Tag Manager API

I have an app that creates a couple of different tags in GTM via the googleapis Node module. I have only used custom triggers until now. I would like to use the system-generated trigger "Initialization - All Pages". However, the triggers list() method only seems to returns custom triggers. How do you get the firingTriggerId for this? This is the tag code:

const createTagRes = await gtm.accounts.containers.workspaces.tags.create({
                    parent: workspacePath,
                    requestBody: {
                        name: configTagName,
                        type: 'googtag',
                        parameter: [
                            {
                                type: 'template',
                                key: 'tagId',
                                value: measurementId,
                            }
                        ],
                        firingTriggerId: [#??? 'Initialization - All Pages'],
                        tagFiringOption: 'oncePerEvent',
                    },
                })

Upvotes: 0

Views: 206

Answers (1)

darrelltw
darrelltw

Reputation: 2372

I am not sure this has been documented by Google

But if you want to use the All Page Views trigger in GTM API.

The trigger id is : "2147479553"

"firingTriggerId": [
    "2147479553"
]

You can create a GTM and set a tag with the trigger

Then export it to see the trigger id in JSON.

Seems like the Trigger id for All Page Views is fixed to 2147479553

Upvotes: 0

Related Questions