Container Versions: list

Requiere autorización

Enumera todos los recursos Container Version que pertenecen a un recurso Container de GTM. Pruébalo ahora o consulta un ejemplo.

Solicitud

Solicitud HTTP

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

Parámetros

Nombre de parámetro Valor Descripción
Parámetros de ruta
accountId string ID de recurso Account de GTM.
containerId string ID de recurso Container de GTM.
Parámetros de consulta opcionales
headers boolean Recupera encabezados solo cuando el valor es "true". Valor predeterminado: false.
includeDeleted boolean También recupera versiones eliminadas (archivadas) cuando el valor es "true". Valor predeterminado: false.

Autorización

Esta solicitud requiere autorización con al menos uno de los ámbitos siguientes. Más información sobre la autenticación y la autorización

Ámbito
https://www.googleapis.com/auth/tagmanager.readonly
https://www.googleapis.com/auth/tagmanager.edit.containerversions
https://www.googleapis.com/auth/tagmanager.edit.containers

Cuerpo de la solicitud

No proporciones un cuerpo de solicitud con este método.

Respuesta

Si este método se realiza correctamente, el cuerpo de respuesta tendrá la siguiente estructura:

{
  "containerVersion": [
    accounts.containers.versions Resource
  ],
  "containerVersionHeader": [
    {
      "accountId": string,
      "containerId": string,
      "containerVersionId": string,
      "name": string,
      "numMacros": string,
      "numRules": string,
      "numTags": string,
      "numTriggers": string,
      "deleted": boolean,
      "numVariables": string
    }
  ]
}
Nombre de propiedad Valor Descripción Notas
containerVersion[] list Todos los recursos Versions que pertenecen a un recurso Container de GTM.
containerVersionHeader[] list Todos los recursos Container Version Header que pertenecen a un recurso Container de GTM.
containerVersionHeader[].accountId string ID de recurso Account de GTM.
containerVersionHeader[].containerId string ID de recurso Container de GTM.
containerVersionHeader[].containerVersionId string ID de recurso Container Version que identifica de forma exclusiva el recurso Container Version de GTM.
containerVersionHeader[].name string Nombre visible del recurso Container Version.
containerVersionHeader[].numMacros string Número de macros del recurso Container Version.
containerVersionHeader[].numRules string Número de reglas del recurso Container Version.
containerVersionHeader[].numTags string Número de etiquetas del recurso Container Version.
containerVersionHeader[].deleted boolean El valor "true" indica que este recurso Container Version se ha eliminado.
containerVersionHeader[].numTriggers string Número de activadores del recurso Container Version.
containerVersionHeader[].numVariables string Número de variables del recurso Container Version.

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 de cliente para obtener una lista de los lenguajes admitidos).

Java

Utiliza la biblioteca de cliente Java.

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

/*
* This request lists all container versions for the authorized user.
*/
try {
  ListContainerVersionsResponse versions = tagmanager.accounts().
      containers().versions().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 versions object.
 * The following code shows how to iterate through them.
 */
for (ContainerVersion version : versions.getContainerVersion()) {
  System.out.println("Account Id = " + version.getAccountId());
  System.out.println("Container Id = " + version.getContainerId());
  System.out.println("Container Version Id = "
      + version.getContainerVersionId());
  System.out.println("Version Name = " +  version.getName());
  System.out.println("Version Deleted = " + version.getDeleted());
  System.out.println("Version Notes = %s" + version.getNotes());
  System.out.println("Version Fingerprint = " + version.getFingerprint());

  // Print the Container details.
  Container container = version.getContainer();
  System.out.println("Container Name = " + container.getName());
  if (container.getDomainName() != null) {
    for (String domain : container.getDomainName()) {
      System.out.println("Domain Name = " + domain);
    }
  }
  System.out.println("Timezone Country Id = "
      + container.getTimeZoneCountryId());
  System.out.println("Timezone Id = " + container.getTimeZoneId());
  System.out.println("Container Notes = " + container.getNotes());
  for (String usageContext : container.getUsageContext()) {
    System.out.println("Usage context = " + usageContext);
  }
  System.out.println("Container Fingerprint = " + container.getFingerprint());

  // Print the Macro details.
  for (Macro macro : version.getMacro()) {
    System.out.println("Macro Id = " + macro.getMacroId());
    System.out.println("Macro Name = " + macro.getName());
    System.out.println("Macro Type = " + macro.getType());
    System.out.println("Macro Notes = " + macro.getNotes());
    if (macro.getParameter() != null) {
      for (Parameter parameter : macro.getParameter()) {
        System.out.println("Parameter Type = " + parameter.getType());
        System.out.println("Parameter Key = " + parameter.getKey());
        System.out.println("Parameter Value = " + parameter.getValue());
      }
    }
    if (macro.getEnablingRuleId() != null) {
      for (String enabllingRuleId : macro.getEnablingRuleId()) {
        System.out.println("Macro Enabling Rule Id = " + enabllingRuleId);
      }
    }
    if (macro.getDisablingRuleId() != null) {
      for (String disablingRuleId : macro.getDisablingRuleId()) {
        System.out.println("Macro Disabling Rule Id " + disablingRuleId);
      }
    }
    System.out.println("Macro Fingerprint = " + macro.getFingerprint());
  }

  // Print the rule details.
  for (Rule rule : version.getRule()) {
    System.out.println("Rule Id = " + rule.getRuleId());
    System.out.println("Rule Name = " + rule.getName());
    System.out.println("Rule Notes = " + rule.getNotes());

    // Get the conditions.
    if (rule.getCondition() != null) {
      for (Condition condition : rule.getCondition()) {
        System.out.println("Condition Type = " + condition.getType());
        if (condition.getParameter() != null) {
          for (Parameter parameter : condition.getParameter()) {
            System.out.println("Parameter Type = " + parameter.getType());
            System.out.println("Parameter Key = " + parameter.getKey());
            System.out.println("Parameter Value = " + parameter.getValue());
          }
        }
      }
    }
    System.out.println("Rule Fingerprint = " + rule.getFingerprint());
  }

  // Print the Tag details.
  if (version.getTag() != null) {
    for (Tag tag : version.getTag()) {
      System.out.println("Tag id = " + tag.getTagId());
      System.out.println("Tag Name = " + tag.getName());
      System.out.println("Tag Type = " + tag.getType());
      if (tag.getFiringRuleId() != null) {
        for (String firingRuleId : tag.getFiringRuleId()) {
          System.out.println("Firing Rule Id  = " + firingRuleId);
        }
      }
      if (tag.getBlockingRuleId() != null) {
        for (String blockingRuleId : tag.getBlockingRuleId()) {
          System.out.println("Blocking Rule Id = " + blockingRuleId);
        }
      }
      System.out.println("Tag Live Only = " + tag.getLiveOnly());

      // Get tag priority.
      Parameter priority = tag.getPriority();
      if (priority != null) {
        System.out.println("Tag Priority Type = " + priority.getType());
        System.out.println("Tag Priority Key = " + priority.getKey());
        System.out.println("Tag Priority Value = " + priority.getValue());
      }

      // Get tag dependencies.
      Parameter dependencies = tag.getDependencies();
      if (dependencies != null) {
        System.out.println("Dependencies Type = " + dependencies.getType());
        System.out.println("Dependencies Key = " + dependencies.getKey());
        System.out.println("Dependencies Value = " + dependencies.getValue());
      }

      System.out.println("Tag Notes = " + tag.getNotes());
      System.out.println("Tag Schedule Start ms = " + tag.getScheduleStartMs());
      System.out.println("Tag Schedule End ms = " + tag.getScheduleEndMs());

      // Get tag parameters.
      if (tag.getParameter() != null) {
        for (Parameter parameter : tag.getParameter()) {
          System.out.println("Parameter Type = " + parameter.getType());
          System.out.println("Parameter Key = " + parameter.getKey());
          System.out.println("Parameter Value = " + parameter.getValue());
        }
      }
      System.out.println("Tag Fingerprint = " + tag.getFingerprint());
    }
  }
}

Python

Utiliza la biblioteca de cliente Python.

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

# This request lists all container versions for the authorized user.
try:
  versions = tagmanager.accounts().containers().versions().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 versions object.
# The following code shows how to iterate through them.
for version in versions.get('containerVersion', []):

  print 'Account Id = %s' % version.get('accountId')
  print 'Container Id = %s' % version.get('containerId')
  print 'Container Version Id = %s' % version.get('containerVersionId')
  print 'Version Name = %s' % version.get('name')
  print 'Version Deleted = %s' % version.get('deleted')
  print 'Version Notes = %s' % version.get('notes')
  print 'Version Fingerprint = %s\n\n' % version.get('fingerprint')

  # Get the container object.
  container = version.get('container', {})
  print 'Container Name = %s' % container.get('name')
  for domain in container.get('domainName', []):
    print 'Domain Name = %s' % domain
  print 'Timezone Country Id = %s' % container.get('timeZoneCountryId')
  print 'Timezone Id = %s' % container.get('timeZone')
  print 'Notes = %s' % container.get('notes')
  for usageContext in container.get('usageContext'):
    print 'Usage Context = %s' % usageContext
  print 'Container Fingerprint = %s\n\n' % container.get('fingerprint')

  # Get the macro objects.
  for macro in version.get('macro', []):
    print 'Macro Id = %s' % macro.get('macroId')
    print 'Macro Name = %s' % macro.get('name')
    print 'Macro Type = %s' % macro.get('type')
    print 'Macro notes = %s' % macro.get('notes')
    print 'Schedule Start ms = %s' % macro.get('scheduleStartMs')
    print 'Schedule End ms = %s' % macro.get('scheduleEndMs')
    for parameter in macro.get('parameter', []):
      print 'Parameter Type = %s' % parameter.get('type')
      print 'Parameter Key = %s' % parameter.get('key')
      print 'Parameter Value = %s' % parameter.get('value')
    for enablingRuleId in macro.get('enablingRuleId', []):
      print 'Macro Enabling Rule Id = %s' % enablingRuleId
    for disablingRuleId in macro.get('disablingRuleId', []):
      print 'Macro Disabling Rule Id = %s' % disablingRuleId
    print 'Macro Fingerprint = %s\n\n' % macro.get('fingerprint')

  # Get the rule object.
  for rule in version.get('rule'):
    print 'Rule Id = %s' % rule.get('ruleId')
    print 'Rule Name = %s' % rule.get('name')
    print 'Rule Notes = %s' % rule.get('notes')
    for condition in rule.get('condition', []):
      print 'Condition Type = %s' % condition.get('type')
      for parameter in condition.get('parameter', []):
        print 'Condition Parameter Type = %s' % condition.get('type')
        print 'Condition Parameter Key = %s' % condition.get('key')
        print 'Condition Parameter Value = %s' % condition.get('value')
    print 'Rule Fingerprint = %s\n\n' % rule.get('fingerprint')

  # Get the tag objects.
  for tag in version.get('tag', []):
    print 'Tag Id = %s' % tag.get('tagId')
    print 'Tag Name = %s' % tag.get('name')
    print 'Tag Type = %s' % tag.get('type')
    for firingRuleId in tag.get('firingRuleId', []):
      print 'Tag Firing Rule Id = %s' % firingRuleId
    for blockingRuleId in tag.get('blockingRuleId', []):
      print 'Tag Blocking Rule Id = %s' % blockingRuleId
    print 'Tag Live Only = %s' % tag.get('liveOnly')

    # Get tag priority.
    priority = tag.get('priority', {})
    print 'Tag Priority Type = %s' % priority.get('type')
    print 'Tag Priority Key = %s' % priority.get('key')
    print 'Tag Priority value = %s' % priority.get('value')

    # Get tag dependencies.
    dependencies = tag.get('dependencies', {})
    print 'printing Dependencies: %s' % dependencies
    print 'Dependencies Type = %s' % dependencies.get('type')
    print 'Dependencies Key = %s' % dependencies.get('key')
    print 'Dependencies Value = %s' % dependencies.get('value')

    print 'Tag Notes = %s' % tag.get('notes')
    print 'Tag Schedule Start ms = %s' % tag.get('scheduleStartMs')
    print 'Tag Schedule End ms = %s' % tag.get('scheduleEndMs')
    for parameter in tag.get('parameter', []):
      print 'Parameter Type = %s' % parameter.get('type')
      print 'Parameter Key = %s' % parameter.get('key')
      print 'Parameter Value = %s' % parameter.get('value')
    print 'Tag Fingerprint = %s\n\n' % tag.get('fingerprint')

Pruébalo

Utiliza el siguiente explorador de APIs para llamar a este método con datos en tiempo real y ver la respuesta.