Google Tag Manager (GTM)
Google Tag Manager (GTM) is a tag management solution that allows you to create and update tags for your web and mobile applications.
Installation
- TypeScript
- Script
- Code
Install the destination via npm
npm i @elbwalker/destination-web-google-gtm
import { elb } from '@elbwalker/walker.js';
import destinationGoogleGTM from '@elbwalker/destination-web-google-gtm';
elb('walker destination', destinationGoogleGTM, config);
Load the destination via dynamic import
<script>
// Upload the dist/index.mjs on your own server
const destination = (
await import(
'https://cdn.jsdelivr.net/npm/@elbwalker/destination-web-google-gtm/dist/index.mjs'
)
).default;
elb('walker destination', destination, config);
</script>
Copy the code from the index.browser.js file
(function () {
'use strict';
var Destination = (() => {})(); // This is the copied code
elb('walker destination', Destination.default, config);
})();
Configuration
Configure your Google Tag Manager destination.
Example
const config = {
custom: {
containerId: "GTM-XXXXXXX",
dataLayer: "dataLayer",
domain: "https://www.googletagmanager.com/gtm.js?id=";
},
};
Custom
Property | Type | Description |
---|---|---|
containerId | string | Google Tag Manager container ID. |
dataLayer | string | Name of the dataLayer array. |
domain | string | Source domain for the Google Tag Manager script. |
When using loadScript: true
the containerId
is required.
info
If you need professional support with your walkerOS implementation, check out our services.