Note: This developer site is moving to developers.google.com/tag-platform and will be redirected by September 30, 2021

Triggers: list

Requires authorization

Lists all GTM triggers of a container. Try it now or see an example.

Request

HTTP request

GET https://www.googleapis.com/tagmanager/v1/accounts/accountId/containers/containerId/triggers

Parameters

Parameter name Value Description
Path parameters
accountId string The GTM Account ID.
containerId string The GTM Container ID.

Authorization

This request requires authorization with at least one of the following scopes (read more about authentication and authorization).

Scope
https://www.googleapis.com/auth/tagmanager.readonly
https://www.googleapis.com/auth/tagmanager.edit.containers

Request body

Do not supply a request body with this method.

Response

If successful, this method returns a response body with the following structure:

{
  "triggers": [
    accounts.containers.triggers Resource
  ]
}
Property name Value Description Notes
triggers[] list All GTM Triggers of a GTM Container.

Examples

Note: The code examples available for this method do not represent all supported programming languages (see the client libraries page for a list of supported languages).

Java

Uses the Java client library.

/*
 * Note: This code assumes you have an authorized tagmanager service object.
 */

/*
 * This request lists triggers for the authorized user.
 */
try {
  ListTriggersResponse triggers = tagmanager.accounts().containers().
      triggers().list("123456", "54321").execute();
} catch (GoogleJsonResponseException e) {
  System.err.println("There was a service error: "
      + e.getDetails().getCode() + " : "
      + e.getDetails().getMessage());
}

/*
 * The results of the list method are stored in the triggers object.
 * The following code shows how to iterate through them.
 */
for (Trigger trigger: triggers.getTriggers()) {
  System.out.println("Account Id = " + trigger.getAccountId());
  System.out.println("Container Id = " + trigger.getContainerId());
  System.out.println("Triger Id = " + trigger.getTriggerId());
  System.out.println("Triger Name = " + trigger.getName());
  System.out.println("Triger Type = " + trigger.getType());
  if (trigger.getCustomEventFilter() != null) {
    for (Condition customEventFilter: trigger.getCustomEventFilter()) {
      System.out.println("Custom Event Filter Type = "
          + customEventFilter.getType());
      for (Parameter parameter: customEventFilter.getParameter()) {
        System.out.println("Parameter Type = " + parameter.getType());
        System.out.println("Parameter Key = " + parameter.getKey());
        System.out.println("Parameter Value = " + parameter.getValue());
      }
    }
  }
  if (trigger.getFilter() != null) {
    for (Condition filter: trigger.getFilter()) {
      System.out.println("Filter Type = " + filter.getType());
      for (Parameter parameter: filter.getParameter()) {
        System.out.println("Parameter Type = " + parameter.getType());
        System.out.println("Parameter Key = " + parameter.getKey());
        System.out.println("Parameter Value = " + parameter.getValue());
      }
    }
  }
  if (trigger.getAutoEventFilter() != null) {
    for (Condition filter: trigger.getAutoEventFilter()) {
      System.out.println("Auto Event Filter Type = " + filter.getType());
      for (Parameter parameter: filter.getParameter()) {
        System.out.println("Parameter Type = " + parameter.getType());
        System.out.println("Parameter Key = " + parameter.getKey());
        System.out.println("Parameter Value = " + parameter.getValue());
      }
    }
  }
  if (trigger.getWaitForTags() != null) {
    Parameter parameter = trigger.getWaitForTags();
    System.out.println("Wait For Tags Type = " + parameter.getType());
    System.out.println("Wait For Tags Key = " + parameter.getKey());
    System.out.println("Wait For Tags Value = " + parameter.getValue());
  }
  if (trigger.getCheckValidation() != null) {
    Parameter parameter = trigger.getCheckValidation();
    System.out.println("Check Validation Type = " + parameter.getType());
    System.out.println("Check Validation Key = " + parameter.getKey());
    System.out.println("Check Validation Value = "
        + parameter.getValue());
  }
  if (trigger.getWaitForTagsTimeout() != null) {
    Parameter parameter = trigger.getWaitForTagsTimeout();
    System.out.println("Wait For Tags Timeout Type = "
        + parameter.getType());
    System.out.println("Wait For Tags Timeout Key = "
        + parameter.getKey());
    System.out.println("Wait For Tags Timeout Value = "
        + parameter.getValue());
  }
  if (trigger.getUniqueTriggerId() != null) {
    Parameter parameter = trigger.getUniqueTriggerId();
    System.out.println("Unique Trigger Id Type = " + parameter.getType());
    System.out.println("Unique Trigger Id Key = " + parameter.getKey());
    System.out.println("Unique Trigger Id Value = "
        + parameter.getValue());
  }
  if (trigger.getEventName() != null) {
    Parameter parameter = trigger.getEventName();
    System.out.println("Event Name Type = " + parameter.getType());
    System.out.println("Event Name Key = " + parameter.getKey());
    System.out.println("Event Name Value = " + parameter.getValue());
  }
  if (trigger.getInterval() != null) {
    Parameter parameter = trigger.getInterval();
    System.out.println("Interval Type = " + parameter.getType());
    System.out.println("Interval Key = " + parameter.getKey());
    System.out.println("Interval Value = " + parameter.getValue());
  }
  System.out.println("Trigger Fingerprint = " + trigger.getFingerprint());
}

Python

Uses the Python client library.

# Note: This code assumes you have an authorized tagmanager service object.

# This request lists triggers for the authorized user.
try:
  triggers = tagmanager.accounts().containers().triggers().list(
      accountId='123456',
      containerId='54321'
  ).execute()
except TypeError, error:
  # Handle errors in constructing a query.
  print 'There was an error in constructing your query : %s' % error

except HttpError, error:
  # Handle API errors.
  print ('There was an API error : %s : %s' %
         (error.resp.status, error.resp.reason))


# The results of the list method are stored in the triggers object.
# The following code shows how to iterate through them.
for trigger in triggers.get('triggers', []):
  print 'Account Id = %s' % trigger.get('accountId')
  print 'Container Id = %s' % trigger.get('containerId')
  print 'Trigger Id = %s' % trigger.get('triggerId')
  print 'Trigger Name = %s' % trigger.get('name')
  print 'Trigger Type = %s' % trigger.get('type')
  for customEventFilter in trigger.get('customEventFilter', []):
    print 'Custom Event Filter Type = %s' % customEventFilter.get('type')
    for parameter in customEventFilter.get('parameter', []):
      print 'Parameter Type = %s' % parameter.get('type')
      print 'Parameter Key = %s' % parameter.get('key')
      print 'Parameter Value = %s' % parameter.get('value')
  for filter in trigger.get('filter', []):
    print 'Filter Type = %s' % filter.get('type')
    for parameter in filter.get('parameter', []):
      print 'Parameter Type = %s' % parameter.get('type')
      print 'Parameter Key = %s' % parameter.get('key')
      print 'Parameter Value = %s' % parameter.get('value')
  for autoEventFilter in trigger.get('autoEventFilter', []):
    print 'Auto Event Filter Type = %s' % autoEventFilter.get('type')
    for parameter in autoEventFilter.get('parameter', []):
      print 'Parameter Type = %s' % parameter.get('type')
      print 'Parameter Key = %s' % parameter.get('key')
      print 'Parameter Value = %s' % parameter.get('value')
  waitForTags = trigger.get('waitForTags', {})
  print 'Wait For Tags Type = %s' % waitForTags.get('type')
  print 'Wait for Tags Key = %s' % waitForTags.get('key')
  print 'Wait for Tags value = %s' % waitForTags.get('value')
  checkValidation = trigger.get('checkValidation', {})
  print 'Check Validation Type = %s' % checkValidation.get('type')
  print 'Check Validation Key = %s' % checkValidation.get('key')
  print 'Check Validation Value = %s' % checkValidation.get('value')
  waitForTagsTimeout = trigger.get('waitForTagsTimeout', {})
  print 'Wait For Tags Timeout Type = %s' % waitForTagsTimeout.get('type')
  print 'Wait For Tags Timeout Key = %s' % waitForTagsTimeout.get('key')
  print 'Wait For Tags Timeout Value = %s' % waitForTagsTimeout.get('value')
  uniqueTriggerId = trigger.get('uniqueTriggerId', {})
  print 'Unique Trigger Id Type = %s' % uniqueTriggerId.get('type')
  print 'Unique Trigger Id Key = %s' % uniqueTriggerId.get('key')
  print 'Unique Trigger Id Value = %s' % uniqueTriggerId.get('Value')
  eventName = trigger.get('eventName', {})
  print 'Event Name Type = %s' % eventName.get('type')
  print 'Event Name Id Key = %s' % eventName.get('key')
  print 'Event Name Id Value = %s' % eventName.get('Value')
  interval = trigger.get('interval', {})
  print 'Interval Type = %s' % interval.get('type')
  print 'Interval Key = %s' % interval.get('key')
  print 'Interval Value = %s' % interval.get('Value')

  print 'Trigger Fingerprint = %s\n\n' % trigger.get('fingerprint')

Try it!

Use the APIs Explorer below to call this method on live data and see the response.