GTM Triggers¶
trigger.py
-
class
gtm_manager.trigger.
GTMTrigger
(trigger=None, path=None, parent=None, **kwargs)[source]¶ Open a specific GTM Trigger.
- Parameters
trigger (dict) – An API representation of the GTM Trigger. If provided, the resource will be not be loaded from the API.
trigger
orpath
argument must be set.path (str) – The API path to the resource, i.e. “accounts/1234/containers/1234/workspaces/1234/trigger/123”. If provided instead of
trigger
, the representation will be loaded from the API.path
ortrigger
argument must be set.parent (str) – Required, when the instance is initialized with a
trigger
argument to explizitly set the parent path, i.e. “accounts/1234/containers/1234/workspaces/1234”**kwargs – Additional keyword args to initialize the base class.
-
property
maxTimerLengthSeconds
¶ Represents a Google Tag Manager Parameter. - Max time to fire Timer Events (in seconds). Only valid for AMP Timer trigger.
- Type
obj
-
property
totalTimeMinMilliseconds
¶ Represents a Google Tag Manager Parameter. - A visibility trigger minimum total visible time (in milliseconds). Only valid for AMP Visibility trigger.
- Type
obj
-
property
uniqueTriggerId
¶ Represents a Google Tag Manager Parameter. - Globally unique id of the trigger that auto-generates this (a Form Submit, Link Click or Timer listener) if any. Used to make incompatible auto-events work together with trigger filtering based on trigger ids. This value is populated during output generation since the tags implied by triggers don”t exist until then. Only valid for Form Submit, Link Click and Timer triggers.
- Type
obj
-
property
verticalScrollPercentageList
¶ Represents a Google Tag Manager Parameter. - List of integer percentage values for scroll triggers. The trigger will fire when each percentage is reached when the view is scrolled vertically. Only valid for AMP scroll triggers.
- Type
obj
-
property
horizontalScrollPercentageList
¶ Represents a Google Tag Manager Parameter. - List of integer percentage values for scroll triggers. The trigger will fire when each percentage is reached when the view is scrolled horizontally. Only valid for AMP scroll triggers.
- Type
obj
-
property
containerId
¶ GTM Container ID.
- Type
str
-
property
waitForTagsTimeout
¶ Represents a Google Tag Manager Parameter. - How long to wait (in milliseconds) for tags to fire when “waits_for_tags” above evaluates to true. Only valid for Form Submission and Link Click triggers.
- Type
obj
-
property
accountId
¶ GTM Account ID.
- Type
str
-
property
waitForTags
¶ Represents a Google Tag Manager Parameter. - Whether or not we should delay the form submissions or link opening until all of the tags have fired (by preventing the default action and later simulating the default action). Only valid for Form Submission and Link Click triggers.
- Type
str
-
property
intervalSeconds
¶ Represents a Google Tag Manager Parameter. - Time between Timer Events to fire (in seconds). Only valid for AMP Timer trigger.
- Type
obj
-
property
eventName
¶ Represents a Google Tag Manager Parameter. - Name of the GTM event that is fired. Only valid for Timer triggers.
- Type
obj
-
property
visibilitySelector
¶ Represents a Google Tag Manager Parameter. - A visibility trigger CSS selector (i.e. “-id”). Only valid for AMP Visibility trigger.
- Type
obj
-
property
workspaceId
¶ GTM Workspace ID.
- Type
str
-
property
customEventFilter
¶ Used in the case of custom event, which is fired iff all Conditions are true.
- Type
list
-
property
parameter
¶ Additional parameters.
- Type
list
-
property
parentFolderId
¶ Parent folder id.
- Type
str
-
property
continuousTimeMinMilliseconds
¶ Represents a Google Tag Manager Parameter. - A visibility trigger minimum continuous visible time (in milliseconds). Only valid for AMP Visibility trigger.
- Type
obj
-
property
selector
¶ Represents a Google Tag Manager Parameter. - A click trigger CSS selector (i.e. “a”, “button” etc.). Only valid for AMP Click trigger.
- Type
obj
-
property
triggerId
¶ The Trigger ID uniquely identifies the GTM Trigger.
- Type
str
-
property
tagManagerUrl
¶ Auto generated link to the tag manager UI
- Type
str
-
property
fingerprint
¶ The fingerprint of the GTM Trigger as computed at storage time. This value is recomputed whenever the trigger is modified.
- Type
str
-
property
visiblePercentageMax
¶ Represents a Google Tag Manager Parameter. - A visibility trigger maximum percent visibility. Only valid for AMP Visibility trigger.
- Type
obj
-
property
path
¶ GTM Trigger”s API relative path.
- Type
str
-
property
name
¶ Trigger display name.
- Type
str
-
property
visiblePercentageMin
¶ Represents a Google Tag Manager Parameter. - A visibility trigger minimum percent visibility. Only valid for AMP Visibility trigger.
- Type
obj
-
property
type
¶ Defines the data layer event that causes this trigger.
- Type
str
-
property
notes
¶ User notes on how to apply this trigger in the container.
- Type
str
-
property
interval
¶ Represents a Google Tag Manager Parameter. - Time between triggering recurring Timer Events (in milliseconds). Only valid for Timer triggers.
- Type
obj
-
property
filter
¶ The trigger will only fire iff all Conditions are true.
- Type
list
-
property
autoEventFilter
¶ Used in the case of auto event tracking.
- Type
list
-
property
limit
¶ Represents a Google Tag Manager Parameter. - Limit of the number of GTM events this Timer Trigger will fire. If no limit is set, we will continue to fire GTM events until the user leaves the page. Only valid for Timer triggers.
- Type
obj
-
property
checkValidation
¶ Represents a Google Tag Manager Parameter. - Whether or not we should only fire tags if the form submit or link click event is not cancelled by some other event handler (e.g. because of validation). Only valid for Form Submission and Link Click triggers.
- Type
obj
-
update
(refresh=False, parameter=None, **kwargs)[source]¶ Update the current trigger. The GTM API does not support a partial update. Therfore, this method will send all fields expliztily set in the method arguments and those cached in the instance properties.
GTMParameters passed in a list as the
parameter
argument, will be merged recursivly with the exsisting parameters based on their parameter key.All other API resource properties can be overwritten by specifying the property name as keyword arguments on the method call.
- Parameters
refresh (bool) – Force a refresh of the entire GTMTrigger instance to prevent implicitly sending stale property data.
parameter (list) –
gtm_manager.parameter.GTMParameter
list to be merged recursivly with the exsisting parameters based on their parameter key.**kwargs – Additional resource properties to update with this call.
- Raises
ValueError –