Plugin Directory

Test out the new Plugin Directory and let us know what you think.

DuracellTomi's Google Tag Manager for WordPress

The first Google Tag Manager plugin for WordPress with business goals in mind.

How can I ...

I created some step by step guides so that you can create the proper settings in Google Tag Manager: http://duracelltomi.com/google-tag-manager-for-wordpress/how-to-articles/

PayPal / 3rd party payment gateway transactions in WooCommerce are not being tracked in Google Analyics

PayPal and some other 3rd party payment gateways does not redirect the user back to your website by default after a successful transaction. It offers the route back for your customer but it can happen that users simply close the browser before they get back to your thankyou page (aka. order received page)

This means that neither Google Analyics tags or any other tags are being fired.

Enable auto return in your payment gateway settings. This will instruct them to show a quick info page after payment and then redirect the user back to your site. This will increase the number of tracked transactions.

Why isn't there an option to blacklist tag/variable classes

Although Google recommends to blacklist tags and variables using classes, I found it is complicated for people to understand what tags and variables are being blacklisted/whitelisted automatically using classses. Therefore I decided to include individual tags and variables on the blacklist tabs.

Please remember that tags are useless without variables so only blacklist variables if you are certain that you do not use them with any tags in your container.

How can I track scroll events in Google Tag Manager?

To track scrolling of your visitor you need to setup some tag in Google Tag Manager.

What type of tags? In most cases you will need Google/Universal Analytics event tags but you can use AdWords remarketing or conversion tags as well to collect micro conversions or to focus only on visitors who spend more time reading your contents.

There are five dataLayer events you can use in your rule definitions:

  • gtm4wp.reading.articleLoaded: the content has been loaded
  • gtm4wp.reading.startReading: the visitor started to scroll. You can use the dataLayer variable timeToScroll to see how many seconds have passed since the article has been loaded
  • gtm4wp.reading.contentBottom: the visitor reached the end of the content (not the page!). timeToScroll dataLayer variable updated
  • gtm4wp.reading.pagebottom: the visitor reached the end of the page. timeToScroll dataLayer variable updated
  • gtm4wp.reading.readerType: at this point we are confident whether the visitor is a 'scanner' or 'reader' depending on how much time have passed since the content has been loaded. readerType dataLayer variable holds the type of the visitor

Can I exclude certain user roles from being tracked?

Google Tag Manager is not just about visitor tracking. The ability to include a Google/Universal Analytics tag is only one feature you can manage.

Therefore there is no need to have an option to exclude the container code snippet on certain cases.

If you want to exclude logged in users or certain user roles, use the corresponding dataLayer variable (visitorType) and an exclude filter in Google Tag Manager.

How do I put the Google Tag Manager container code next to the opening body tag?

Go to the admin section of the plugin and select "Custom" from the placement settings. This way my plugin does not put the code snippet into the footer of the page.

In this case you have to edit your template files. Go to wp-content/plugins/themes/<your theme dir> and edit header.php. In most cases you will find the opening <body> tag here.

If you can not find it, contact the author of the theme and ask for instructions.

In case you found the opening <body> tag, open a new line just after it and insert this line of code:

<?php if ( function_exists( 'gtm4wp_the_gtm_tag' ) ) { gtm4wp_the_gtm_tag(); } ?>

Be careful not to include this line inside any <div>, <p>, <header>, <article> and so on. It can break you theme.

There is also a solution named "Codeless" which tries to add the container code to the right place but without additional theme tweaking. This is still experimental, use it wisely.

Why can not this plugin insert the container snippet after the opening body tag automatically?

Currently WordPress has two 'commands' or 'hooks' that a programmer can use: one for the <head> section and one for the bottom of <body>. There is no way to inject any content after the opening body tag without manually editing your template files.

Fortunately some theme authors already resolved this so in some cases you do not need to edit your template. I suggest first to select the Custom placement and use Google Tag Assistant Chrome browser extension to check whether the container code is placed as expected.

If it shows an error, go and edit your theme manually.

Facebook like/share/send button events do not fire for me, why?

It is a limitation of Facebook. Click event tracking is only available for html5/xfbml buttons. If you or your social plugin inserts the Facebook buttons using IFRAMEs (like Sociable), it is not possible to track likes.

Requires: 3.4.0 or higher
Compatible up to: 4.6.4
Last Updated: 4 months ago
Active Installs: 80,000+


4.6 out of 5 stars


12 of 33 support threads in the last two months have been marked resolved.

Got something to say? Need help?


Not enough data

1 person says it works.
0 people say it's broken.

100,1,1 100,1,1
100,2,2 100,1,1
100,2,2 100,1,1 100,1,1 100,1,1
100,1,1 100,1,1
100,1,1 100,1,1
100,1,1 100,2,2