Containers: create

Yetkilendirme gerektirir

Kapsayıcı oluşturur. Hemen deneyin veya bir örneğe göz atın.

İstek

HTTP isteği

POST https://www.googleapis.com/tagmanager/v1/accounts/accountId/containers

Parametreler

Parametre adı Değer Açıklama
Yol parametreleri
accountId string GTM Hesap Kimliği.

Yetkilendirme

Bu istek, aşağıdaki kapsamla yetkilendirme gerektirir (kimlik doğrulama ve yetkilendirme hakkında daha fazla bilgi edinin).

Kapsam
https://www.googleapis.com/auth/tagmanager.edit.containers

İstek içeriği

İstek gövdesinde, aşağıdaki özelliklere sahip bir Container kaynağı sağlayın:

Mülk adı Değer Açıklama Notlar
Zorunlu mülkler
name string Kapsayıcının görünen adı. yazılabilir
timeZoneCountryId string Kapsayıcı Ülke Kimliği. yazılabilir
timeZoneId string Kapsayıcı Saat Dilimi Kimliği. yazılabilir
usageContext[] list Kapsayıcı için Kullanım Bağlamlarının Listesi. Geçerli değerler şunları içerir: web, android, ios. yazılabilir
İsteğe Bağlı Özellikler
domainName[] list Kapsayıcı ile ilişkili alan adlarının isteğe bağlı listesi. yazılabilir
enabledBuiltInVariable[] list Etkin yerleşik değişkenlerin listesi. Geçerli değerler şunları içerir: pageUrl, pageHostname, pagePath, referrer, event, clickElement, clickClasses, clickId, clickTarget, clickUrl, clickText, formElement, formClasses, formId, formTarget, formUrl, formText, errorMessage, errorUrl, errorLine, newHistoryFragment, oldHistoryFragment, newHistoryState, oldHistoryState, historySource, containerVersion, debugMode, randomNumber, containerId. yazılabilir
notes string Kapsayıcı Notları. yazılabilir

Yanıt

Başarılı olursa bu yöntem, yanıt gövdesinde bir Kapsayıcı kaynağı döndürür.

Örnekler

Not: Bu yöntem için kullanıma sunulan kod örnekleri, desteklenen tüm programlama dillerini kapsamaz (Desteklenen dillerin listesi için istemci kitaplıkları sayfasını inceleyin).

Java

Java istemci kitaplığı'nı kullanmalıdır.

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

/*
 * This request creates a new container for the authorized user.
 */

// Construct the container object.
Container container = new Container();
container.setName("Example Container");
container.setTimeZoneCountryId("US");
container.setTimeZoneId("America/Los_Angeles");
container.setUsageContext(Arrays.asList("web", "android", "ios"));

try {
  Container response = tagmanager.accounts().
      containers().create("12345", container).execute();
} catch (GoogleJsonResponseException e) {
  System.err.println("There was a service error: "
      + e.getDetails().getCode() + " : "
      + e.getDetails().getMessage());
}


/*
 * The results of the create method are stored in the response object.
 * The following code shows how to access the created Id and Fingerprint.
 */
System.out.println("Container Id = " + response.getContainerId());
System.out.println("Container Fingerprint" + response.getFingerprint());

Python

Python istemci kitaplığı'nı kullanır.

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

# This request creates a new container.
try:
  response = tagmanager.accounts().containers().create(
      accountId='123456',
      body={
          'name': 'Example Container',
          'timeZoneCountryId': 'US',
          'timeZoneId': 'America/Los_Angeles',
          'usageContext': ['web', 'android']
      }
  ).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 create method are stored in the response object.
# The following code shows how to access the created id and fingerprint.
print response.get('containerId')
print response.get('fingerprint')

Deneyin.

Aşağıdaki API Gezgini'ni kullanarak canlı verilerde bu yöntemi çağırın ve yanıtı görün.