Triggers: list

承認が必要です

コンテナのすべての GTM トリガを一覧表示します。 こちらからお試しいただくか、をご覧ください。

リクエスト

HTTP リクエスト

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

パラメータ

パラメータ名 説明
パスパラメータ
accountId string GTM アカウント ID。
containerId string GTM コンテナ ID。

承認

このリクエストは、少なくとも以下のスコープの 1 つによって承認される必要があります(詳細については、認証と承認に関する記事をご覧ください)。

スコープ
https://www.googleapis.com/auth/tagmanager.readonly
https://www.googleapis.com/auth/tagmanager.edit.containers

リクエスト本文

このメソッドをリクエストの本文に含めないでください。

レスポンス

成功すると、このメソッドは次の構造を含むレスポンスの本文を返します。

{
  "triggers": [
    accounts.containers.triggers Resource
  ]
}
プロパティ名 説明 備考
triggers[] list GTM コンテナのすべての GTM トリガー。

注: このメソッドで使用可能なコード例では、サポートされているプログラミング言語すべての例を示しているわけではありません(サポートされている言語の一覧については、クライアント ライブラリ ページをご覧ください)。

Java

Java クライアント ライブラリを使用します。

/*
 * 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

Python クライアント ライブラリを使用します。

# 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')

演習

以下の API Explorer を使用し、ライブデータに対してこのメソッドを呼び出して、レスポンスを確認してみましょう。