GTM Workspaces¶
gtm workspace.py
-
class
gtm_manager.workspace.
GTMWorkspace
(workspace=None, path=None, **kwargs)[source]¶ Open a specific GTM Workspace.
- Parameters
workspace (dict) – An API representation of the GTM Workspace. If provided, the resource will be not be loaded from the API. workspace or path argument must be set.
path (str) – The API path to the resource, i.e “accounts/1234/containers/1234/workspaces/1234”. If provided instead of workspace, the representation will be loaded from the API. path or workspace argument must be set.
**kwargs – Additional keyword args to initialize the base class.
-
property
description
¶ Account display name
- Type
str
-
property
name
¶ Account display name
- Type
str
-
property
workspaceId
¶ Account display name
- Type
str
-
property
tagManagerUrl
¶ Account display name
- Type
str
-
property
fingerprint
¶ Account display name
- Type
str
-
property
path
¶ Account display name
- Type
str
-
property
accountId
¶ Account display name
- Type
str
-
property
containerId
¶ Account display name
- Type
str
-
quick_preview
(refresh=True)[source]¶ Get a quick_preview of the current workspace state from the API.
- Parameters
Args –
refresh (bool) – If quick_preview has already been loaded from the API, force another API request to get the latest quick_preview.
- Returns
An instance of
gtm_manager.version.GTMVersion
-
clear_all_assets
(refresh=True)[source]¶ Clear all assets from the current workspace.
- Parameters
refresh (bool) – If quick_preview has already been loaded from the API, force another API request to get the latest quick_preview.
-
trigger_map
(refresh=True)[source]¶ Create a trigger map from the current workspace.
- Parameters
refresh (bool) – If quick_preview has already been loaded from the API, force another API request to get the latest quick_preview.
- Returns
A dict having all triggerNames and triggerIds as strings keys with their corresponding triggerIds and triggerNames as string values. The All Pages trigger will always be added as default. For example:
{ "2147479553": "All Pages", "All Pages": "2147479553", "Click - My Button": "1", "1": "Click - My Button", }
-
folder_map
(refresh=True)[source]¶ Create a folder map from the current workspace.
- Parameters
refresh (bool) – If quick_preview has already been loaded from the API, force another API request to get the latest quick_preview.
- Returns
A dict having all folderNames and folderIds as strings keys with their corresponding folderIds and folderName as string values. For example:
{ "My Folder": "1", "My Other Folder": "2", "1":"My Folder", "2": "My Other Folder", }
-
disable_built_ins
(built_in_type)[source]¶ Disable built-ins in the current workspace.
Possible values are documented here <https://developers.google.com/tag-manager/api/v2/reference/accounts/containers/workspaces/built_in_variables/create>
- Parameters
built_in_type (list of str) – A list of the built in types as strings the call should disable.
-
create_tag
(asset_body)[source]¶ Create a tag in the current workspace.
@TODO: Add writeable fields.
- Parameters
asset_body (dict) – An API representation of a GTM Tag.
- Returns
An instance of
gtm_manager.tag.GTMTag
-
create_trigger
(asset_body)[source]¶ Create a trigger in the current workspace.
@TODO: Add writeable fields.
- Parameters
asset_body (dict) – An API representation of a GTM Trigger.
- Returns
An instance of
gtm_manager.trigger.GTMTrigger
-
create_variable
(asset_body)[source]¶ Create a variable in the current workspace.
@TODO: Add writeable fields.
- Parameters
asset_body (dict) – An API representation of a GTM Variable.
- Returns
An instance of
gtm_manager.variable.GTMVariable
-
create_folder
(name, notes='')[source]¶ Create a folder in the current workspace.
@TODO: Add writeable fields.
- Parameters
asset_body (dict) – An API representation of a GTM Folder.
- Returns
An instance of
gtm_manager.folder.GTMFolder
-
create_build_ins
(asset_body)[source]¶ Create built-ins in the current workspace.
- Parameters
built_in_type (list of str) – A list of the built in types as strings the call should enable.
List all tags from the current workspace.
- Parameters
refresh (bool) – If quick_preview has already been loaded from the API, force another API request to get the latest quick_preview.
- Returns
A list of
gtm_manager.tag.GTMTag
.
-
list_triggers
(refresh=False)[source]¶ List all triggers from the current workspace.
- Parameters
refresh (bool) – If quick_preview has already been loaded from the API, force another API request to get the latest quick_preview.
- Returns
A list of
gtm_manager.triggers.GTMTrigger
.
-
list_variables
(refresh=False)[source]¶ List all variables from the current workspace.
- Parameters
refresh (bool) – If quick_preview has already been loaded from the API, force another API request to get the latest quick_preview.
- Returns
A list of
gtm_manager.variable.GTMVariable
.
-
list_folders
(refresh=False)[source]¶ List all folders from the current workspace.
- Parameters
refresh (bool) – If quick_preview has already been loaded from the API, force another API request to get the latest quick_preview.
- Returns
A list of
gtm_manager.folder.GTMFolder
.
-
list_built_in_variables
(refresh=False)[source]¶ List all built in variables from the current workspace.
- Parameters
refresh (bool) – If quick_preview has already been loaded from the API, force another API request to get the latest quick_preview.
- Returns
A list of
gtm_manager.built_in_variable.GTMBuiltInVariable
.
-
get_tag_by_name
(tag_name, refresh=False)[source]¶ Get a GTM Tag from the GTM Workspace by its name.
- Parameters
tag_name (str) – The exact name to look for in the GTM Workspace.
refresh (bool) – If quick_preview has already been loaded from the API, force another API request to get the latest quick_preview.
- Returns
An instance of
gtm_manager.tag.GTMTag
.- Raises
-
get_trigger_by_name
(trigger_name, refresh=False)[source]¶ Get a GTM Trigger from the GTM Workspace by its name.
- Parameters
trigger_name (str) – The exact name to look for in the GTM Workspace.
refresh (bool) – If quick_preview has already been loaded from the API, force another API request to get the latest quick_preview.
- Returns
An instance of
gtm_manager.trigger.GTMTrigger
.- Raises
-
get_variable_by_name
(variable_name, refresh=False)[source]¶ Get a GTM Variable from the GTM Workspace by its name.
- Parameters
variable_name (str) – The exact name to look for in the GTM Workspace.
refresh (bool) – If quick_preview has already been loaded from the API, force another API request to get the latest quick_preview.
- Returns
An instance of
gtm_manager.variable.GTMVariable
.- Raises
-
create_version
(name, notes='')[source]¶ Create a new version from the current state of the workspace.
@TODO: add descroption for sync or publishing errors
- Parameters
name (str) – The GTM Version display name
notes (str) –
- Returns
An instance of
gtm_manager.version.GTMVersion
.