נדרשת הרשאה
מעדכן מאקרו של GTM. אפשר לנסות עכשיו או לראות דוגמה.
בקשה
בקשת HTTP
PUT https://www.googleapis.com/tagmanager/v1/accounts/accountId/containers/containerId/macros/macroId
פרמטרים
שם הפרמטר | Value | התיאור |
---|---|---|
פרמטרים של נתיב | ||
accountId |
string |
מספר החשבון ב-GTM. |
containerId |
string |
מזהה מאגר התגים של GTM. |
macroId |
string |
מזהה המאקרו של GTM. |
פרמטרים אופציונליים של שאילתה | ||
fingerprint |
string |
כשמזינים את טביעת האצבע, היא צריכה להתאים לטביעת האצבע של המאקרו באחסון. |
הרשאות
בקשה זו מחייבת הרשאה בהיקף הבא (למידע נוסף על אימות והרשאה).
היקף |
---|
https://www.googleapis.com/auth/tagmanager.edit.containers |
גוף הבקשה
בגוף הבקשה, מספקים משאב מאקרו עם המאפיינים הבאים:
שם הנכס | Value | התיאור | הערות |
---|---|---|---|
מאפיינים נדרשים | |||
parameter[].type |
string |
סוג הפרמטר. הערכים החוקיים הם:
הערכים הקבילים הם:
|
ניתן לכתיבה |
type |
string |
סוג המאקרו GTM. | ניתן לכתיבה |
מאפיינים אופציונליים | |||
disablingRuleId[] |
list |
עבור כלים מכילים של מכשירים ניידים בלבד: רשימה של מזהי כללים להשבתת פקודות מאקרו מותנות; המאקרו מופעל אם אחד מכללי ההפעלה מתקיים וכל כללי ההשבתה אינם נכונים. מטופל כקבוצה לא ממוינת. | ניתן לכתיבה |
enablingRuleId[] |
list |
עבור כלים מכילים של מכשירים ניידים בלבד: רשימה של מזהי כללים להפעלת פקודות מאקרו מותנות; המאקרו מופעל אם אחד מכללי ההפעלה מתקיים וכל כללי ההשבתה אינם נכונים. מטופל כקבוצה לא ממוינת. | ניתן לכתיבה |
name |
string |
שם התצוגה של המאקרו. | ניתן לכתיבה |
notes |
string |
המשתמש הערות לגבי אופן ההחלה של מאקרו זה בכלי הקיבול. | ניתן לכתיבה |
parameter[] |
list |
הפרמטרים של רכיב המאקרו. | ניתן לכתיבה |
parameter[].key |
string |
המפתח בעל השם שמזהה פרמטר באופן ייחודי. נדרש לפרמטרים ברמה העליונה, וגם לערכי מפה. המערכת התעלמה מערכים ברשימה. | ניתן לכתיבה |
parameter[].list[] |
list |
הפרמטרים של פרמטר הרשימה הזו (המערכת תתעלם מהמפתחות). | ניתן לכתיבה |
parameter[].map[] |
list |
הפרמטרים של פרמטר המפה הזה (חייבים לכלול מפתחות, המפתחות חייבים להיות ייחודיים). | ניתן לכתיבה |
parameter[].value |
string |
ערך של פרמטר (עשוי להכיל הפניות מאקרו כגון "") בהתאם לסוג שצוין. | ניתן לכתיבה |
scheduleEndMs |
long |
חותמת הזמן של הסיום, באלפיות השנייה, לתזמון מאקרו. | ניתן לכתיבה |
scheduleStartMs |
long |
חותמת הזמן של ההתחלה באלפיות השנייה לתזמון מאקרו. | ניתן לכתיבה |
תשובה
אם הפעולה בוצעה ללא שגיאות, השיטה הזו תחזיר משאב מאקרו בגוף התגובה.
דוגמאות
הערה: דוגמאות הקוד הזמינות לשיטה זו לא מייצגות את כל שפות התכנות הנתמכות (רשימת השפות הנתמכות זמינה בדף של ספריות המשתמשים).
Java
משתמש בספריית הלקוח של Java.
/* * Note: This code assumes you have an authorized tagmanager service object. */ /* * This request updates an existing macro for the authorized user. */ // Construct the macro object. Macro macro = new Macro(); macro.setName("Updated URL Macro"); macro.setType("u"); // Construct the parameters. Parameter arg0 = new Parameter(); arg0.setType("template"); arg0.setKey("component"); arg0.setValue("URL"); Parameter arg1 = new Parameter(); arg1.setType("template"); arg1.setKey("customUrlSource"); arg1.setValue("{{element}}"); // set the parameters on the macro. macro.setParameter(Arrays.asList(arg0, arg1)); try { Macro response = tagmanager.accounts().containers(). macros().update("123456", "54321", "18", macro).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
עושה שימוש בספריית הלקוח של Python.
# Note: This code assumes you have an authorized tagmanager service object. # This request updates an existing macro for the authorized user. try: response = tagmanager.accounts().containers().macros().update( accountId='123456', containerId='54321', macroId='19', body={ 'name': 'Sample URL Macro', 'type': 'u', 'parameter': [ { 'type': 'template', 'key': 'component', 'value': 'URL' }, { 'type': 'template', 'key': 'customUrlSource', 'value': '{{element}}' } ] } ).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')
רוצה לנסות?
ניתן להשתמש ב-APIs Explorer שבהמשך כדי לקרוא לשיטה הזו בנתונים בזמן אמת ולראות את התגובה.