Tracking | Enhanced Data Layer Support for WordPress (GTM4WP Plugin)

Data Layer 

The data layer is a JavaScript object used to pass information from a website to Google Analytics.
 
"Pushing" information to the data layer is done programmatically by executing a script like the one below.
 
<script>
  window.dataLayer = window.dataLayer || [];
  window.dataLayer.push({'event': 'ChannelMix.conversion'});
</script>
 
Utilizing the data layer is considered best practice for multiple reasons: 
  • Maintainability - the data layer should not be impacted by front end changes to the site
  • Reliability - data can be pushed programmatically from backend systems
  • Extensibility - data can be collect even if it is not presented on-screen

Because this data is pushed programmatically, it can present a barrier to entry for non-developers. 

GTM4WP Plugin

The GTM4WP (Google Tag Manager for WordPress) plugin helps WordPress sites push data to the data layer for consumption by Google Analytics, without the need for custom code. 

If you run a WordPress site, follow this link to install the plugin: Installing the plugin

In short, you will have to install the plugin via WordPress then input your GTM Container ID in the box below.

mceclip9.png

Capturing Data Layer Variables

The values we are pushing to the data layer will not be automatically collected by Google Analytics (GA). We must create Data Layer Variables in GTM in order to capture these values and pass them to GA as event parameters or custom dimensions. 

Example Data Layer Snippet

mceclip15.png

Corresponding Data Layer Variable in Google Tag Manager

Say you want to capture the revenue value above so it can be sent with the Transaction/Purchase event Tag. The Data Layer Variable Name below will return this value when it is present in the data layer. In this case the data layer object contains nested dictionaries, which requires dot (".") notation to access. 

mceclip16.png

After creating the data layer variable above, you may include it as an event parameter as demonstrated below. Keep in mind that this variable value will remain undefined until the corresponding data layer value is pushed. 

mceclip17.png

Enabling Ecommerce - WooCommerce, Shopify, Printify

These instructions are only for WordPress WooCommerce, Shopify, and Printify sites.

After installing the WP4GTM plugin, login to as WordPress admin and navigate to the plugin settings:

Plugins > Installed Plugins > Google Tag Manager for WordPress > Settings

mceclip0.png

From within Settings, choose the tabs shown below: Integration > WooCommerce. 

  1. Check the box next to Track enhanced e-commerce.
  2. Set the number next to Products per impression. 
  3. Click Save Changes.

mceclip1.png

Finally, deactivate any ecommerce Transactions Tags you may have already implemented through GTM. 

mceclip3.png

Contact Forms

  1. From GTM4WP plugin settings, navigate to Events > General events.
  2. From here, you can check the box next to Form fill events in order to gain supplemental data layer support.

mceclip8.png

Geo Data 

  1. From GTM4WP plugin settings, navigate to Basic data > Weather & geo data
  2. From here, you can check the box next to Geo data push those details to the data layer.

This is an experimental service which requires an IPStack.com API key. 

mceclip6.png

Other Options

Authentication Data - Under Basic data > Visitors you will find options for data layer support of authenticated/logged in users. Check any that can enhance your tracking implementation. You may choose to capture the values with GTM Data Layer Variables for inclusion with Tags as custom dimensions, event parameter, or label values. 

mceclip10.png

Example of including the data variable as a Page View User Property

mceclip11.png

Scroll Tracking - use this feature to push data layer values regarding user scroll activities. This may be useful if you want to analyze how many users view the entire contents of a web page, like articles or blogs. 

mceclip12.png

Conclusion

The GTM4WP plugin can greatly enhance your tracking in terms of accuracy and maintainability. Install the plugin and configure it as needed to enhance your data layer with more information. Then capture those values using data layer variables created through GTM. Finally, include those variable values within your Tags as Event Parameters for analysis in Google Analytics. 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.