Skip to content

jaymurphy1997/grav-plugin-gtm-plugin

Repository files navigation

Gtm Plugin Plugin

The Gtm Plugin Plugin is an extension for Grav CMS. Installs Google Tag Manager code and updates the dataLayer without any changes to code.

Installation

Installing the Gtm Plugin plugin can be done in one of three ways: The GPM (Grav Package Manager) installation method lets you quickly install the plugin with a simple terminal command, the manual method lets you do so via a zip file, and the admin method lets you do so via the Admin Plugin.

GPM Installation (Preferred)

To install the plugin via the GPM, through your system's terminal (also called the command line), navigate to the root of your Grav-installation, and enter:

bin/gpm install gtm-plugin

This will install the Gtm Plugin plugin into your /user/plugins-directory within Grav. Its files can be found under /your/site/grav/user/plugins/gtm-plugin.

Manual Installation

To install the plugin manually, download the zip-version of this repository and unzip it under /your/site/grav/user/plugins. Then rename the folder to gtm-plugin. You can find these files on GitHub or via GetGrav.org.

You should now have all the plugin files under

/your/site/grav/user/plugins/gtm-plugin

NOTE: This plugin is a modular component for Grav which may require other plugins to operate, please see its blueprints.yaml-file on GitHub.

Admin Plugin

If you use the Admin Plugin, you can install the plugin directly by browsing the Plugins-menu and clicking on the Add button.

Configuration

Before configuring this plugin, you should copy the user/plugins/gtm-plugin/gtm-plugin.yaml to user/config/plugins/gtm-plugin.yaml and only edit that copy.

Here is the default configuration and an explanation of available options:

enabled: true
GTM Container ID: Add the Container ID here
  • GTM Container ID: Fill in with the GTM Container ID from Google Tag Manager (typically of the form "GTM-.*")

Note that if you use the Admin Plugin, a file with your configuration named gtm-plugin.yaml will be saved in the user/config/plugins/-folder once the configuration is saved in the Admin.

Usage

First you will need to create a Google Tag Manager container. Follow the steps below:

  1. Sign in to your Google Tag Manager account.
  2. Select the Admin tab.
  3. Select an account from the dropdown in the ACCOUNT column.
  4. Select a Container from the dropdown in the CONTAINER column.
  5. In the upper right hand of the WORKSPACE OVERVIEW, click the link starting with "GTM-" - copy this full string - it is your GTM CONTAINER ID
  6. Copy the GTM CONTAINER ID (a string like GTM-XXXXXXX)

Now add this Container ID to the Grav Gtm Plugin

  1. Login to your Grav CMS Admin
  2. Click on the Plugins menu on the left side of your Admin panel.
  3. Click on the "Gtm Plugin" link.
  4. Enable the plugin
  5. Add the Container ID to the "GTM Container ID" plugin field.
  6. Click on the Save button (upper right hand corner).

Credits

Inspired by the Grav Ganalytics Plugin, John Linhart ([email protected]), Christian Worreschk ([email protected]) https://github.com/escopecz/grav-ganalytics Thanks!

To Do

  • Allow different 'dataLayer' names
  • Add website and page information to the dataLayer to allow marketing tag capture and future analysis

About

This is a GravCMS Plugin to install Google Tag Manager

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages