GoogleTagManager
Setup
Sign up for Google Tag Manager and create a new web container.
Add the Google Tag Manager container snippet to your site.
During development and testing it is often helpful to use Google Tag Manager's Container Preview mode. Follow the instructions here to enable it.
Install the target:
Usage
You may also provide an options object when creating the target:
Event Definitions
Variables
Notes
This target will push all generated event objects to the
window.dataLayer
by default. As detailed in the GTM docs.Only event objects with an
event
property will trigger a Custom Event in Google Tag Manager.If an event object doesn't have an
event
property, but has ahitType
property, this target will create anevent
property and set it to thehitType
string. This feature allows you to use the event definitions exposed by the Google Analytics target For example:If you return anything but an object from an event definition
(e.g. undefined, null) then the target will skip over that event and won't
push anything to
window.dataLayer
.
Last updated