Richiede l'autorizzazione
Aggiorna un contenitore. Prova subito o guarda un esempio.
Richiesta
Richiesta HTTP
PUT https://www.googleapis.com/tagmanager/v1/accounts/accountId/containers/containerId
Parametri
Nome del parametro | Valore | Descrizione |
---|---|---|
Parametri del percorso | ||
accountId |
string |
L'ID account GTM. |
containerId |
string |
L'ID contenitore GTM. |
Parametri di query facoltativi | ||
fingerprint |
string |
Se fornita, questa impronta deve corrispondere a quella del contenitore nello spazio di archiviazione. |
Autorizzazione
Questa richiesta richiede l'autorizzazione con il seguente ambito (scopri di più su autenticazione e autorizzazione).
Ambito |
---|
https://www.googleapis.com/auth/tagmanager.edit.containers |
Corpo della richiesta
Nel corpo della richiesta, fornisci una risorsa Containers con le seguenti proprietà:
Nome proprietà | Valore | Descrizione | Note |
---|---|---|---|
Proprietà obbligatorie | |||
usageContext[] |
list |
Elenco dei contesti di utilizzo per il contenitore. I valori validi sono: web, android, ios . |
scrivibile |
Proprietà facoltative | |||
domainName[] |
list |
Elenco facoltativo di nomi di dominio associati al contenitore. | scrivibile |
enabledBuiltInVariable[] |
list |
Elenco delle variabili integrate attivate. I valori validi sono: 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 . |
scrivibile |
name |
string |
Nome visualizzato del contenitore. | scrivibile |
notes |
string |
Note contenitore. | scrivibile |
timeZoneCountryId |
string |
ID paese contenitore. | scrivibile |
timeZoneId |
string |
ID fuso orario container. | scrivibile |
Risposta
In caso di esito positivo, questo metodo restituisce una risorsa Containers nel corpo della risposta.
Esempi
Nota: gli esempi di codice disponibili per questo metodo non rappresentano tutti i linguaggi di programmazione supportati (consulta la pagina relativa alle librerie client per un elenco dei linguaggi supportati).
Java
Utilizza la libreria client Java.
/* * Note: This code assumes you have an authorized tagmanager service object. */ /* * This request updates an existing container for the authorized user. */ // Construct the container object. Container container = new Container(); container.setName("Example Container"); container.setNotes("Example Container Notes."); container.setTimeZoneCountryId("US"); container.setTimeZoneId("America/Los_Angeles"); container.setUsageContext(Arrays.asList("web", "android", "ios")); try { Container response = tagmanager.accounts(). containers().update("123456", "54321", container).execute(); } catch (GoogleJsonResponseException e) { System.err.println("There was a service error: " + e.getDetails().getCode() + " : " + e.getDetails().getMessage()); } /* * The results of the update method are stored in the response object. * The following code shows how to access the updated name and fingerprint. */ System.out.println("Updated Name = " + response.getName()); System.out.println("Updated Fingerprint = " + response.getFingerprint());
Python
Utilizza la libreria client Python.
# Note: This code assumes you have an authorized tagmanager service object. # This request updates an existing container. try: response = tagmanager.accounts().containers().update( accountId='123456', containerId='54321', 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 update method are stored in the response object. # The following code shows how to access the updated name and fingerprint. print 'Updated Name = %s' % response.get('name') print 'Updated Fingerprint = %s' % response.get('fingerprint')
Prova.
Utilizza Explorer API di seguito per chiamare questo metodo sui dati in tempo reale e visualizzare la risposta.