Macros

The macros of a container. Macros represent values that are evaluated at runtime. You can reference macros when you configure rules and tags. For details the properties that can be set for Google Tag Manager macros see the Macro Dictionary Reference. For information about how users set up and use macros, see Macros in the Google Tag Manager Help Center.

For a list of methods for this resource, see the end of this page.

Resource representations

Represents a Google Tag Manager macro.

{
  "accountId": string,
  "containerId": string,
  "macroId": string,
  "name": string,
  "type": string,
  "notes": string,
  "scheduleStartMs": long,
  "scheduleEndMs": long,
  "parameter": [
    {
      "type": string,
      "key": string,
      "value": string,
      "list": [
        (Parameter)
      ],
      "map": [
        (Parameter)
      ]
    }
  ],
  "enablingRuleId": [
    string
  ],
  "disablingRuleId": [
    string
  ],
  "fingerprint": string,
  "parentFolderId": string
}
Property name Value Description Notes
accountId string GTM Account ID.
containerId string GTM Container ID.
disablingRuleId[] list For mobile containers only: A list of rule IDs for disabling conditional macros; the macro is enabled if one of the enabling rules is true while all the disabling rules are false. Treated as an unordered set. writable
enablingRuleId[] list For mobile containers only: A list of rule IDs for enabling conditional macros; the macro is enabled if one of the enabling rules is true while all the disabling rules are false. Treated as an unordered set. writable
fingerprint string The fingerprint of the GTM Macro as computed at storage time. This value is recomputed whenever the macro is modified.
macroId string The Macro ID uniquely identifies the GTM Macro.
name string Macro display name. writable
notes string User notes on how to apply this macro in the container. writable
parameter[] list The macro's parameters. writable
parameter[].key string The named key that uniquely identifies a parameter. Required for top-level parameters, as well as map values. Ignored for list values. writable
parameter[].list[] list This list parameter's parameters (keys will be ignored). writable
parameter[].map[] list This map parameter's parameters (must have keys; keys must be unique). writable
parameter[].type string The parameter type. Valid values are:
  • boolean: The value represents a boolean, represented as 'true' or 'false'
  • integer: The value represents a 64-bit signed integer value, in base 10
  • list: A list of parameters should be specified
  • map: A map of parameters should be specified
  • template: The value represents any text; this can include macro references (even macro references that might return non-string types)


Acceptable values are:
  • "boolean"
  • "integer"
  • "list"
  • "map"
  • "template"
writable
parameter[].value string A parameter's value (may contain macro references such as "{{myMacro}}") as appropriate to the specified type. writable
parentFolderId string Parent folder id.
scheduleEndMs long The end timestamp in milliseconds to schedule a macro. writable
scheduleStartMs long The start timestamp in milliseconds to schedule a macro. writable
type string GTM Macro Type. writable

Methods

Use the methods below to create, modify, delete or retrieve macros.

create
Creates a GTM macro.
delete
Deletes a GTM macro.
get
Gets a GTM macro.
list
Lists all GTM macros of a container.
update
Updates a GTM macro.