This plugin allows you to configure the "ContainerID" from the control panel and inject the GTM tags into the template.
This plugin requires Craft CMS 4.0.0 or later. Version 1.x of this plugin supports Craft CMS 3.x.
To install the plugin, follow these instructions.
-
Open your terminal and go to your Craft project:
cd /path/to/project
-
Then tell Composer to load the plugin:
composer require la-haute-societe/craft-google-tag-manager
-
In the Control Panel, go to Settings → Plugins and click the “Install” button for Google Tag Manager.
You can configure the containerID from the Craft Control Panel.
Copy the code below and paste it into your layout as high as possible in the <head>
section
of the page:
{{ craft.googleTagManager.headSection() }}
You must also paste this code immediately after the opening tag <body>
:
{{ craft.googleTagManager.bodySection() }}