GTM Kit – Google Tag Manager plugin

Google Tag Manager (GTM) is a powerful tool for WordPress users that allows them to easily add tracking codes and other snippets to their website.

GTM Kit

I have developed a Google Tag Manager WordPress plugin and it’s called GTM Kit.

GTM Kit

There are many other plugins out there, so why develop another GTM plugin? When I develop a WooCommerce shop I customize the frontend to such an extent that I usually must customize the Google Tag Manager implementation. I’m fanatic about page speed and SEO so I won’t accept bloated JavaScript, which again means that I have to customize any other plugin.

GTM Kit is fast and flexible, and it suits my needs when building a custom WooCommerce site.

What are the benefits of using Google Tag Manager?

Google Tag Manager is a great tool for WordPress users because it allows them to easily add tracking codes and other snippets to their website without having to manually add code. This makes it easier to track user behavior, measure conversions, and optimize your website. Additionally, GTM allows you to manage tags, triggers, and variables in one place, making it easier to keep track of all your tags. Finally, GTM is free to use, so you don’t have to worry about any additional costs.

For advanced users there is a huge benefit in setting up Google Tag Manager up for tracking Google Analytics 4 event. Obviously, this allows you to use Google Analytics but more importantly it allows you to reuse the GA4 events for other purposes in Facebook, Google Ads etc. This means the frontend will be less bloated.

Getting started with GTM Kit

If you’re ready to get started with GTM Kit, the first step is to install and activate the plugin. Once you’ve done that, you can create your Google Tag Manager container if you don’t already have one and add your Container ID. Finally, you need to click the container activation switch and click save.

That’s it!

Google Tag Manager container

GTM Kit will include the container in the header and push a simple data layer object to Google Tag Manager, which some basic data.

To get started with tracking WooCommerce you must activate the WooCommerce integration but that is simple as well.

Of course, there are many more option that you can tweak but this gets you a long way.

Features for developers

One feature that really makes you life easier as a developer is the ability to override settings values with constants in wp-config.php.

define( 'GTMKIT_CONTAINER_ID', 'GTM-XXXXXXX' );

define( 'GTMKIT_CONTAINER_ACTIVE', false );

If you have got a WooCommerce store you probably have a dev, test or staging site. You may not want to run the production container on these sites and with the constants above you deactivate container or specify a different one.

This means that you don’t have to worry about the container when copy a production DB to a local development site.

When you are dealing with highly customized WooCommerce stores there will likely be cases where the standard JavaScript of GTM Kit is not compatible with your site. There is a setting to dequeue the standard JavaScript in GTM Kit, which is more reliable than trying to dequeue it programmatically using wp_dequeue_script(). If you need to customize the script, you can find the source ind Github repository.

Of course GTM Kit has a lot of filter and action hooks that you can use to customize the plugin to your needs.

What lies ahead for GTM Kit?

I will continue to actively develop the plugin and I’m open for suggestions of new features. Currently there is no fixed roadmap and features will be developed as the need arises.

Most importantly GTM Kit will continue to be free and open source.

Posted in #

Torben Lundsgaard Avatar

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *