Containers: create

इसके लिए, अनुमति लेना ज़रूरी है

कंटेनर बनाता है. इसे अभी आज़माएं या उदाहरण देखें.

अनुरोध

एचटीटीपी अनुरोध

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

पैरामीटर

पैरामीटर का नाम वैल्यू ब्यौरा
पाथ पैरामीटर
accountId string GTM खाता आईडी.

अनुमति देना

इस अनुरोध के लिए नीचे दिए गए दायरे के साथ अनुमति की ज़रूरत है (पुष्टि करने और अनुमति देने के बारे में ज़्यादा पढ़ें).

स्कोप
https://www.googleapis.com/auth/tagmanager.edit.containers

अनुरोध का मुख्य भाग

अनुरोध के मुख्य हिस्से में, नीचे दी गई प्रॉपर्टी के साथ कंटेनर संसाधन दें:

प्रॉपर्टी का नाम वैल्यू ब्यौरा ज़रूरी जानकारी
ज़रूरी प्रॉपर्टी
name string कंटेनर का डिसप्ले नेम. लिखने योग्य
timeZoneCountryId string कंटेनर के देश का आईडी. लिखने योग्य
timeZoneId string कंटेनर का टाइम ज़ोन आईडी. लिखने योग्य
usageContext[] list कंटेनर के लिए, इस्तेमाल के कॉन्टेक्स्ट की सूची. मान्य वैल्यू में ये शामिल हैं: web, android, ios. लिखने योग्य
वैकल्पिक प्रॉपर्टी
domainName[] list कंटेनर से जुड़े डोमेन नेम की वैकल्पिक सूची. लिखने योग्य
enabledBuiltInVariable[] list चालू बिल्ट-इन वैरिएबल की सूची. मान्य वैल्यू में ये शामिल हैं: 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. लिखने योग्य
notes string कंटेनर के नोट. लिखने योग्य

जवाब

कामयाब रहने पर, यह तरीका रिस्पॉन्स के मुख्य हिस्से में कंटेनर संसाधन दिखाता है.

उदाहरण

ध्यान दें: इस तरीके के लिए दिए गए कोड के उदाहरणों में इसके साथ काम करने वाली सभी प्रोग्रामिंग भाषाएं नहीं दिखाई गई हैं (इसके साथ काम करने वाली भाषाओं की सूची के लिए क्लाइंट लाइब्रेरी वाला पेज देखें).

Java

Java क्लाइंट लाइब्रेरी का इस्तेमाल करता है.

/*
 * 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 क्लाइंट लाइब्रेरी का इस्तेमाल करता हो.

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

इसे आज़माएं!

इस तरीके को लाइव डेटा पर कॉल करने और रिस्पॉन्स देखने के लिए, नीचे दिए गए एपीआई एक्सप्लोरर का इस्तेमाल करें.