Requiere autorización
Muestra una lista de todos los activadores de GTM de un contenedor. Pruébalo ahora y ve un ejemplo.
Solicitud
Solicitud HTTP
GET https://www.googleapis.com/tagmanager/v1/accounts/accountId/containers/containerId/triggers
Parámetros
Nombre del parámetro | Valor | Descripción |
---|---|---|
Parámetros de ruta de acceso | ||
accountId |
string |
El ID de la cuenta de GTM. |
containerId |
string |
El ID del contenedor de GTM. |
Autorización
Esta solicitud requiere autorización con al menos uno de los siguientes alcances (obtén más información acerca de la autenticación y autorización).
Permiso |
---|
https://www.googleapis.com/auth/tagmanager.readonly |
https://www.googleapis.com/auth/tagmanager.edit.containers |
Cuerpo de la solicitud
No proporciones un cuerpo de solicitud con este método.
Respuesta
Si se aplica correctamente, este método muestra un cuerpo de respuesta con la siguiente estructura:
{ "triggers": [ accounts.containers.triggers Resource ] }
Nombre de la propiedad | Valor | Descripción | Notas |
---|---|---|---|
triggers[] |
list |
Todos los activadores de GTM de un contenedor de GTM. |
Ejemplos
Nota: Los ejemplos de código disponibles para este método no representan todos los lenguajes de programación admitidos (consulta la página de bibliotecas cliente para consultar una lista de lenguajes admitidos).
Java
Usa la biblioteca cliente de 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
Usa la biblioteca cliente de 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')
Pruébala
Usa el Explorador de APIs que aparece a continuación para llamar a este método con datos en tiempo real y ver la respuesta.