WordPress.org

Plugin Directory

DuracellTomi's Google Tag Manager for WordPress

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

How can I implement enhanced e-commerce in Google Tag Manager

I created a step-by-step guide for this: http://duracelltomi.com/google-tag-manager-for-wordpress/how-to-articles/setup-enhanced-ecommerce-tracking

PayPal transactions in WooCommerce are not being tracked in Google Analyics

PayPal does not redirect the user back to your website by default. 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 PayPal settings. This will instruct PayPal 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/macro classes

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

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

How can I track add-to-cart events in WooCommerce

To track add-to-cart events using classic transactions you have to catch the dataLayer event gtm4wp.addProductToCart

There are 3 additional dataLayer variables that can be accessed during the event using classic ecommerce tracking:

  • productName: the name of the product where the cart button has been pressed
  • productSKU: the SKU you entered in your product settings
  • productID: the ID of the WordPress post that holds your product data

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.

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.0.1 or higher
Compatible up to: 4.2.2
Last Updated: 2015-5-4
Active Installs: 10,000+

Ratings

5 out of 5 stars

Support

5 of 25 support threads in the last two months have been resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1 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,2,2
100,1,1
100,1,1 100,1,1
100,1,1
100,1,1