GTM4WP – A Google Tag Manager (GTM) plugin for WordPress Plugin
Advanced tag management for WordPress with Google Tag Manager
Google Tag Manager (GTM) is Google’s free tool for everyone to manage and deploy analytics and marketing tags as well as other code snippets
using an intuitive web UI. To learn more about this tool, visit the official website.
This plugin places the GTM container code snippets onto your WordPress website so that you do not need to add it manually.
Multiple containers are also supported!
The plugin complements your GTM setup by pushing page meta data and user information into the so called data layer.
Google’s official help pages includes more details about the data layer.
PHP 7.4 is required to use this plugin.
GTM container code placement
The original GTM container code is divided into two parts:
The first part is a javascript code snippet that is added to the <head>
section of every page of the website.
This part is critical to enable all features of GTM, and this plugin helps to place this part
correctly on your site.
The second part is an iframe snippet that acts as a failsafe/fallback should users’ JavaScript be disabled.
Google recommends – for best performance – to place this code snippet directly after the opening <body>
tag on each page.
Albeit not ideal, it will work when placed lower in the code. This plugin provides a code placement option for the second code snippet.
If your WordPress theme is compatible with the additions of WordPress 5.2 then this plugin will place this second code to the right place.
Users of the Genisis theme, GeneratePress theme, Elementor, Oxygen Builder and Beaver Builder Theme will also have this placed correctly.
To utilize this, set the compatibility mode in plugin options to off.
All other users can place this second code snippet using a custom PHP code (“Manually coded” option) or select the so called “Footer” option to
add the code lower in the code (it is not the recommended way but will work)
Basic data included
- post/page titles
- post/page dates
- post/page category names
- post/page tag names
- post/page author ID and name
- post/page ID
- post types
- post format
- post count on the current page + in the current category/tag/taxonomy
- custom terms associated with any post type
- logged in status
- logged in user role
- logged in user ID (to track cross device behaviour in Google Analytics)
- logged in user email address (both unhashed and SHA256 hased values to be used with tracking)
- logger in user creation date
- site search data
- site name and id (for WordPress multisite instances)
- IP address of the visitor (please use the explicit consent of the visitor to utilize this)
Browser / OS / Device data
- browser data (name, version, engine)
- OS data (name, version)
- device data (type, manufacturer, model)
Data is provided using the WhichBrowser library: http://whichbrowser.net/
Weather data
(beta)
Push data about users’ current weather conditions into the dataLayer. This can be used to generate weather-related
audience/remarketing lists on ad platforms and allows for user segmentation in your web analytics solutions:
- weather category (clouds, rain, snow, etc.)
- weather description: more detailed data
- temperature in Celsius or Fahrenheit
- air pressure
- wind speed and degrees
Weather data is queried from Open Weather Map. Depending on your websites traffic, additional fees may apply:
http://openweathermap.org/price
An (free) API key from OpenWeatherMap is required for this feature to work.
ipstack.com is used to determine the site visitor’s location. A (free) API key from IPStack.com is required for this feature to work:
https://ipstack.com/product
Media player events
(experimental)
Track users’ interaction with any embedded media:
DataLayer events can be chosen to fire upon media player load, media is being played, paused/stopped and optionally when
the user reaches 10, 20, 30, …, 90, 100% of the media duration.
Tracking is supported for embedded media using the built-in oEmbed feature of WordPress as well as most other media plugins
and copy/pasted codes. Players injected into the website after page load are not currently supported.
Scroll tracking
Fire tags based on how the visitor scrolls from the top to the bottom of a page.
An example would be to separate “readers” (who spend a specified amount of time on a page) from “scrollers”
(who only scroll through within seconds). You can use these events to fire Analytics tags and/or remarketing/conversion tags
(for micro conversions).
Scroll tracking is based on the solution originally created by
- Nick Mihailovski
- Thomas Baekdal
- Avinash Kaushik
- Joost de Valk
- Eivind Savio
- Justin Cutroni
Original script:
http://cutroni.com/blog/2012/02/21/advanced-content-tracking-with-google-analytics-part-1/
Blacklist & Whitelist Tag Manager tags, triggers and variables
To increase website security, you have the option to white- and blacklist tags/triggers/variables.
You can prevent specific tags from firing or the use of certain variable types regardless of your GTM setup.
If the Google account associated with your GTM account is being hacked, an attacker could easily
execute malware on your website without accessing its code on your hosting server. By blacklisting custom HTML tags
and/or custom JavaScript variables you can secure the Tag Manager container.
Integration
Google Tag Manager for WordPress integrates with several popular plugins. More integration to come!
- Contact Form 7: fire an event when a Contact Form 7 form was submitted with any result (mail sent, mail failed, spam detected, invalid input)
- WooCommerce:
- Implementation of GA4 E-commerce
- Does not support promotions since WooCommerce does not have such a feature (yet)
- Does not support refunds
- Compatibility with High Performance Order Storage (HPOS)
- AMP: load your AMP container on the AMP version of your pages
- Cookiebot: use automatic cookie blocking mode if needed
- Google Consent Mode v2: fire the “default” command with specific consent flags to integrat with non-certified Consent Management Platforms (CMPs) and plugins.
Server side containers
If you are using a server side container
you can enter your custom domain name and custom path to load gtm.js from your there.
Exclude specific user roles from being tracked
You can set which user roles needs to be excluded from tracking when a user with that role visits the frontend. This will completely disable the container code for that user.
Installation
- Upload
duracelltomi-google-tag-manager-for-wordpress
to the /wp-content/plugins/
directory - Activate the plugin through the ‘Plugins’ menu in WordPress
- Go to Settings / Google Tag Manager and enter your Google Tag Manager container ID and set additional options
Screenshots
Admin panel
Basic settings
Events
Integration panel
Advanced settings
Scroll tracking
FAQ
How can I … Tutorials for various Google Tag Manager settings and implementation are available on the plugin’s website:
https://gtm4wp.com/setup-gtm4wp-features
PayPal / 3rd party payment gateway transactions in WooCommerce are not being tracked in Google Analytics PayPal and some other 3rd party payment gateways do not redirect users back to your website upon successful transaction by default.
It offers the route back for your customer but it can happen that users close the browser before arriving at your thankyou page
(aka. order received page). This means that neither Google Analytics tags or any other tags have the chance to fire.
Enable auto-return in your payment gateway settings. This will instruct them to show a quick info page after payment
and redirect the user back to your site. This will improve the accuracy and frequency of tracked transactions.
Purchase event is not tracked with WooCommerce If you are using a 3rd party plugin that alters the default order received page in a way that does not utilize the integration hooks
of WooCommerce then this can happen. Either stop using this 3rd party plugin or ask them to better mimic the behavior of the
default order received page by supporting the woocommerce is_order_received_page and the woocommerce_thankyou actions and filters.
Why isn’t there an option to blacklist tag/variable classes Although Google recommends to blacklist tags and variables using classes, people struggle to know
which tags/variables gets affected. Therefore I opted for individual tags and variables rather than classes
on the blacklist tabs.
Regarding variables; ensure they are not part of any critical tags as blacklisting such variables will render said tags useless.
How can I track scroll events in Google Tag Manager? Google Tag Manager supports basic scroll depth tracking based on percentage or pixels natively. This plugin adds
additional scroll tracking events, more focused on capturing the users’ intent and/or engagement.
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. The
timeToScroll
dataLayer variable stores duration since the article loaded (in seconds) - 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: based on time spent since article loaded we determine whether the user is a ‘scanner’ or ‘reader’ and store this in the
readerType
dataLayer variable
Example use cases: using these events as triggers, you can fire Google Universal Analytics and/or Google Ads remarketing/conversion tags
to report micro conversions and/or to serve ads only to visitors who spend more time reading your content.
Changelog
1.20.2
- Fix: Wrong ID parameter used tracking product variations (id instead of item_id). Thanks micmaf
- Fix: do not track add_to_cart in product lists when ‘Select options’ or ‘View products’ buttons are clicked
- Fix: JavaScript reference error while updating cart count in WooCommerce. Thanks Sakuk3
- Fix: hash customerBillingEmailHash just like orderData.customer.billing.email_hash (for enhanced conversions, use the value in orderData)
- Added: minimum required WooCommerce version (currently 5.0+) is displayed now on GTM4WP admin
1.20.1
- Fix: do not load GTM container when OFF and console.log OFF. Thanks morvy
- Fix: reverted a change where item_id in ecommerce data layer was converted to numeric type when the value was a numeric value. It will be kept as a string to preserve compatibility with other integrations.
- Fix: JavaScript error when element ID not set correctly in scroll tracking
- Changed: better normalize and hash user data with WooCommerce + orderData variable for enhanced conventions
- Changed: PHP code optimization by hans2103
- Added: New filter to be able to modify data in the orderData variable on a WooCommerce order received page. Filter can be accessed either using the GTM4WP_WPFILTER_EEC_ORDER_DATA constant or the gtm4wp_eec_order_data string.
1.20
THE BIG CLEANUP RELEASE!
Lots of deprecated features removed.
The code of WooCommerce integration was cleaned and restructured, if you have any custom code that relies on GTM4WP internal data structure,
please update the plugin on a test version of your website before updating your live site!
- Removed: deprecated Universal Analytics events for WooCommerce
- Removed: deprecated filter GTM4WP_WPFILTER_AFTER_DATALAYER/gtm4wp_after_datalayer
- Removed: deprecated filter GTM4WP_WPFILTER_ADDGLOBALVARS/gtm4wp_add_global_vars
- Removed: deprecated feature that puts the ‘Do not track’ option of the browser into the data layer. It is a deprecated browser feature therefore removed from this plugin.
- Removed: deprecated Google Optimize integration
- Removed: deprecated constants GTM4WP_OPTION_BLACKLIST_MACRO_* and GTM4WP_OPTION_BLACKLIST_
- Removed: deprecated WordPress filter GTM4WP_WPFILTER_GETTHEGTMTAG (deprecated in v1.16)
- Changed: lots of internal function names and variable names changed, although is not recommended to depend on them, if you did, check your code
- Changed: renamed WP filter gtm4wp_datalayer_on_pageload to gtm4wp_woocommerce_datalayer_on_pageload to better reflect when it is called.
- Changed: orderData data layer variable in WooCommerce integration now includes keys to better support enhanced conversions setup:
- orderData.customer.billing.first_name_hash
- orderData.customer.billing.last_name_hash
- orderData.customer.billing.phone_hash
- Deprecated: orderData.customer.billing.emailhash, please update to use orderData.customer.billing.email_hash (with an underscore)
- Added: stockstatus key into the product array of every ecommerce action. Returns the value of WP_Product->get_stock_status(). Thanks hans2103.
- Added: integration with WebToffee GDPR Cookie Consent plugin. GTM4WP can not fire a GTM event when user consent changes or when a previously stored consent has been loaded.
- Fixed: add_payment_info and add_shipping_info events were not fired during checkout submit when not fired before on the page.
- Fixed: GTM4WP will only look for the user’s IP address in the REMOTE_ADDR server variable. You may enter a custom HTTP header instead in plugin settings.
1.19.1
- Fixed: run additional checks when determing product category to prevent PHP errors in certain cases
- Fixed: corrected Consent Mode flag names in admin page description texts
1.19
WARNING!
Universal Analytics / GA3 ecommerce events deprecated!
Please update your GTM setup so that it does not rely on any of the following GTM4WP events and the old ecommerce data layer:
* gtm4wp.productClickEEC
* gtm4wp.addProductToCartEEC
* gtm4wp.removeFromCartEEC
* gtm4wp.checkoutOptionEEC
* gtm4wp.checkoutStepEEC
* gtm4wp.changeDetailViewEEC
* gtm4wp.orderCompletedEEC
Instead of the above events, you can use the new GA4 ecommerce events (add_to_cart, purchase, etc.)
In the Universal Analytics GTM tag now you have an option to use the GA4 ecommerce data in the data layer.
If you are on GA360 and still collecting ecommerce data, you need to update your GTM setup to use that option firing on the GA4 ecommerce events.
- Updated: WooCommerce integration now accepts the primary category selection of Yoast SEO and Rank Math SEO
- Updated: use the gtm4wp_admin_page_capability filter to modify the capability needed to use the admin page (thanks emreerkan)
- Fixed: price did not include the .00 postfix for integers in the add_to_cart event
- Added: if needed, you can turn on clearing the ecommerce object before a new GA4 event is being pushed.
- Added: support for Google Consent Mode default command for use cases where the consent management tool does not support it already
1.18.1
- Fixed: PHP notice about Undefined variable: blocking_cookie
1.18
- Fixed: error while checking the new customer status in WooCommerce on the order received page (thanks morvy)
- Fixed: Call to a member function get_meta() on null error on WooCommerce order received page (thanks Dekadinious)
- Updated: WordPress and WooCommerce compatibility
- Updated: Deprecated Google Optimize integration as the tool is sunsetting in September 2023
- Added: Create a cookie named block_gtm4wp_geoip after a specific user selected cookie preferences. Set the value to either “yes”, “true”, “on” or “1” and the GeoIP (and weather API) feature will be disabled for that particular user
1.17
- Added: pagePostTerms data layer variable will now also include a meta key with post meta values that does not start with the _ character. This should allow to utilize custom fields added by plugins like Advanced Custom Fields.
- Added: new filter: gtm4wp_post_meta_in_datalayer to limit which post meta should be present with with the previously added feature.
- Added: ability to use a custom path for your server side GTM container. This makes GTM4WP compatible with services like stape.io
- Added: new advanced option to disable browser console.log() messages on frontend
- Added: new filter: gtm4wp_purchase_datalayer to be able to alter data layer content for the purchase data
- Added: new filter: gtm4wp_datalayer_on_pageload to be able to alter data layer content generated during page load
- Added: customerBillingState and customerShippingState on WooCommerce order received page, thanks massimo-maimeri
- Added: High Performance Order Storage (HPOS) compatibility for WooCommerce
- Updated: WooCommerce integration will also check target attitbute of product links while firing select_item event, thanks [robklo])(https://github.com/robklo)
- Updated: YouTube tracking will not load on pages not containing a YouTube block or a YouTube iframe
- Fixed: add_to_cart event on grouped products not working when SKU is selected as product ID in plugin options.
- Fixed: more reliable new_customer flag working with guest orders of existing customers, thanks morvy
1.16.2
- Fixed: server side GTM hostname did not work if domain name included a hyphen character
- Fixed: user login and user registration data layer events were swapped, thanks danvy for the fix
- Fixed: JavaScript error in Chrome around event.target.closest calls, thanks pinkasey for the fix
- Fixed: cast _ga_tracked variable as integer to make the identical operator work correctly, thanks Irfan for the suggestion
- Fixed: removed extra code added in 1.14 that reloads pages in Safari in WooCommerce integration. It broke some sites.
- Updated: required PHP version raised to 7.4. Currently, this is not a hard requirement but from now I could include updates that will require this PHP version.
1.16.1
- Fixed: GTM ID not properly set in noscript tag (probably fixes some 403 errors with firewalls too)
1.16
This plugin version does not add or update any functionality.
After recent events, the code of the plugin has been checked line by line to see where additional security checks can be added.
The code has been formatted to better support readability for other programmers.
Deprecated:
* gtm4wp_get_the_gtm_tag hook and the corresponding GTM4WP_WPFILTER_GETTHEGTMTAG PHP constant.
* gtm4wp_add_global_vars hook and the corresponding GTM4WP_WPFILTER_ADDGLOBALVARS PHP constant. Use gtm4wp_add_global_vars_array / GTM4WP_WPFILTER_ADDGLOBALVARS_ARRAY instead.
* gtm4wp_after_datalayer hook and the corresponding GTM4WP_WPACTION_AFTER_DATALAYER PHP constant. Use gtm4wp_output_after_datalayer / GTM4WP_WPACTION_AFTER_DATALAYER instead witch can be used in the same way but it is an action instead of a filter.
Upcoming version will come with important changes:
* Minimum PHP version will be raised to 7.4: this will allow me to add even more safety measures
* Minimum supported WooCommerce version will be raised to WooCommerce 5.0: with this I can remove some very old compatibility code
* Deprecated features will be removed (aims to simplify code for better maintenance):
* Do not track flag of the browser added into data layer
* Legacy version of WooCommerce dynamic remarketing (using ecomm_ parameters)
The goal of all these changes aim to keep the plugin code clean and free from legacy solutions.
1.15.2
- Fixed: Stored XSS when using the scroll tracking feature and an admin changes the content element ID into a JavaScript code.
- Deprecated option: ‘do not track’ flag of the browser. This browser feature itself is now deprecated
Full scan of the plugin is also in works to fix any other possible XSS issue.
1.15.1
- Fixed: JavaScript error with the newly added console logging to debug code placement issues
- Fixed: possible XSS Vulnerability if Cloudflare country code option enabled. Thanks Guillaume Fortier
- Fixed: proven XSS Vulnerability if adding site search into the data layer was enabled. Original report by not_stoppable. Root cause analysis by Cory Buecker.
- Removed: deprecated feature Google Ads remarketing. This is the outdated, classic way using the google_tag_params variable.
- Dev: removed PHP constant GTM4WP_WPFILTER_COMPILE_REMARKTING (related to removed Google Ads remarketing feature)
- Dev: removed gtm4wp_compile_remarkering WordPress filter (related to removed Google Ads remarketing feature)
Note to plugin users: I sincerely appologize for the vulnerabilities. To make sure, such cases do not happen again,
the next version will be fully dedicacted to go through every peace of code and make sure proper data processing is happening in GTM4WP.
1.15
- Added: pagePostType data layer variable will now return 404-error on 404 pages and search-results on search result pages
- Added: Google Tag Manager container code can be disabled for specific WordPress user roles under Advanced plugin options. A browser console warning will be shown in such cases to prevent confusion
- Added: support for all Contact Form 7 events for more granual tracking: gtm4wp.contactForm7MailSent, gtm4wp.contactForm7MailFailed, gtm4wp.contactForm7SpamDetected, gtm4wp.contactForm7InvalidInput
- Added: additional data layer variables for date attributes: pagePostDateDayName, pagePostDateHour, pagePostDateMinute, pagePostDateIso, pagePostDateUnix – by ajtatum
- Fixed: unclickable products in WooCommerce product lists in Firefox when visiting site in Strict privacy mode or using private browsing
- Fixed: tracking step 2 on WooCommerce checkout page was broken
- Updated: removed CDATA blocks as they are not required in simple HTML and they break some cases where code optimizer is being used
- Updated: products per impression in WooCommerce integration now defaults to 10 instead of 0. This allows view_item_list event to fire on new sites as well
- Updated: code placement options. Separated container on/off option and replaced code placement with the new terminology: compatibility mode
- Updated: removed optional chaining operator usage (?.) in JavaScript codes for better compatibility with outdated browsers
- Updated: changed ‘Do not flag orders as being tracked’ description to be more precise about what happens if turned on or left off
- Updated: if you enter your custom domain name for server side tagging with the https:// prefix, it will be removed before domain name validation
- Updated: all script blocks to be ignored by Cookiebot if this integration is enabled
- Updated: do not track WooCommerce order where payment failed
1.14.2
- Fixed: undefined google_business_vertical
- Fixed: missing product price in product impression data
- Fixed: better compatibility with cache plugins and lazy load functionalities
- Fixed: Added optional chaining operator to form move tracker code
1.14.1
1.14
- Added: support for tracking WooCommerce Block based product lists, except the “All Products” block
- Added: support for new_customer parameter for Google Smart Shopping campaigns
- Added: SHA256 hashed versions of data layer variables containing email addresses: customerBillingEmailHash on WooCommerce order received pages and visitorEmailHash on generic uses cases
- Added: WooCommerce – if for some reason is_order_received_page() reports false on the order received page, woocommerce_thankyou hook will be used as backup
- Updated: removed jQuery dependency from plugin modules: contact form 7 integration, form move tracker, Vimeo, YouTube, Soundcloud, partly WooCommerce
- Updated: moved the hidden helper span element in products lists to the end of the product box to make more compatible with themes
- Updated: more consistent retrieval of product categories – by Dekadinious
- Updated: gtm4wp_product_readded_to_cart cookie replaced with a WooCommerce session variable to use fewer cookies in this plugin
- Updated: gtm4wp_user_logged_in, gtm4wp_user_registered and gtm4wp_last_weatherstatus cookies are now HTTP only cookies
- Updated: replaced deprecated jQuery method and event usage in WP admin
- Updated: added rel=”noopener” to links pointing to external sites on WP admin page
- Updated: Hiding the iframe tag from assistive technologies as it provides no functionality for the end user. This will also alleviate a11y audit warnings.
- Fixed: proper values for visitorType data layer variable
- Fixed: replaced unsafe usage of eval() in WooCommerce QuickView plugin integration
- Fixed: type check of the order ID obtained from a cookie before using the value
- Fixed: navigation issues in Safari if browser loads previous page from cache. GTM4WP will now force Safari to always reload pages.
- Fixed: Do not trigger browser change event in WooCommerce checkout page submit event handler. It caused issues with other 3rd party plugins.
- Fixed: HTML5 detection. – by Sjoerd
- Fixed: Username not included in datalayer if no other user attribute is included – by StaymanHou
1.13.1
- Fix: better PHP8 compatibility
- Fix: PHP notice on admin page
1.13
WARNING!
If you are using the geo or weather options of this plugin, make sure your hosting is using PHP 7.0 or newer!
If you are using the WooCommerce integration with enhanced ecommerce, once again you will need to update your GTM container.
Please check the setup article to see what needs to be changed.
The goal is to keep this setup in the upcoming versions.
- Added: Google Business Vertical option to populate Google Ads dynamic remarketing
- Added: Make automatic cookie blocking mode of Cookiebot to work with your Google Tag Manager container (new option in the Integration tab)
- Added: support for server side containers with custom domains
- Added: improved duplacate WooCommerce order tracking prevention by also checking the age of the order. You can adjust the value in minutes on the plugin options page – by Code-Craze
- Fixed: prices rounded to 2 decimals in the data layer (WooCommerce integration)
- Fixed: select_item event fired multiple times (at least twice)
- Fixed: frontend protection to preveent double tracking transactions had a bug
- Fixed: missing product detail and first checkout step tracking in WooCommerce shops with Enhanced Ecommerce
- Fixed: JavaScript type error if product category is a number
- Updated: WhichBrowser v2.1.1 (requires PHP 7.0 or newer)
- Updated: descriptions of WooCommerce tracking methods to emphasize the importance to migrate from standard to enhanced ecommerce
- Updated: added links to enhanced ecommerce setup guides (GA3 and GA4)
1.12.3
No new or updated functionality, but updated WooCommerce compatibility.
IMPORTANT!
If you are using the WooCommerce integration and enhanced ecommerce, please update your ecommerce event trigger to include gtm4wp.orderCompletedEEC as well.
https://gtm4wp.com/how-to-articles/how-to-setup-enhanced-ecommerce-tracking
1.12.2
If you are upgrading from 1.11.x, please read the previous changelog entry for v1.12
- Fixed: error message in WooCommerce integration on PHP 8 hosts
- Fixed: PHP notice about non existing blacklist-enable array key
1.12.1
If you are upgrading from 1.11.x, please read the previous changelog entry for v1.12
- Fixed: PHP notice while saving admin options
1.12
WARNING!
If you are using the blacklist/whitelist feature of the plugin, review these options after upgrade as they could break because of a fundamental rework of this feature.
- Added: support for Google Analytics 4 version of ecommerce data layer
- Fixed: safer IP address validation in geo and weather data features
- Updated: removed deprecated events: download links, email links, social links -> such can be now tracked with native Google Tag Manager triggers
- Updated: removed support for WooCommerce versions before v3.2
- Updated: ‘Blacklist tags’ tab renamed to ‘Security’
- Updated: complete rework of blacklist/whitelist feature to use the latest tag/trigger/variable list of Google
- Deprecated: classic ecommerce tracking will be removed later this year, please upgrade to enhanced ecommerce tracking
- Deprecated: standard Google Ads remarketing variable will be removed soon as the Google Ads remarketing tag template can easily use any of your Google Tag Manager variables
- Deprecated: the old fashioned way of using Google Ads remarketing with the ecomm_ prefixed data layer variables will be removed soon. Instructions for upgrade will be published on gtm4wp.com once this feature gets updated in an upcoming plugin version
1.11.6
- Fixed: do not track hidden products in the cart in WooCommerce shops
- Fixed: do not fire add to cart event if button is in a disabled state
- Fixed: fixed translation of an admin text
- Fixed: needs_shipping_address() calls were sometimes broken in WooCommerce shops, added additional checks to prevent
- Updated: removed the body_class method of adding the iframe/noscript container code (page builders and the standard wp_body_open hook remains supported)
1.11.5
- Fixed: new Google Optimize container ID format accepted now
1.11.4
- Fixed: fire gtm4wp.checkoutStepEEC and gtm4wp.checkoutOptionEEC events if there is only one shipping method available and it is hidden from the user
- Fixed: decrease checkout step numbers 3 and 4 if shipping destination is set to ‘Force shipping to the customer billing address’ in WooCommerce. This way there will be no gap in Checkout behaviour report in Google Analytics.
- Updated: tested version number for WooCommerce
1.11.3
- Fixed: use var_export instead of var_dump in some debug code,
- Fixed: apply WooCommerce option for tax inclusion on the order received page as well
- Fixed: JavaScript errors in Vimeo player
- Updated: do not add type attribute to script elements if theme suppors HTML5
- Updated: tested version numbers for WordPress and WooCommerce
1.11.2
WARNING!
If you are upgrading directly from v1.10.x, please read the changelog of v1.11 since it includes many important notices!
No change in plugin code, WP.org deployment of v1.11.1 included wrong directories
1.11.1
WARNING!
If you are upgrading directly from v1.10.x, please read the changelog of v1.11 since it includes many important notices!
- Fixed: PHP notice about undefined order_items variable if the new ‘Order data in data layer’ is turned off
- Fixed: PHP notice about missing brand array key if no brand taxonomy is selected in GTM4WP options
1.11
WARNING!
Please read the changelog very carefully as there are many important changes and removed features which could need your attention before updating!
- Added Oxygen Builder and Beaver Builder Theme support – you can now use the codeless placement option without issues
- Added ability to fix the Google Tag Manager ID and GTM Environment parameters in wp-config.php. To use it, create PHP constants with the names
** GTM4WP_HARDCODED_GTM_ID
** GTM4WP_HARDCODED_GTM_ENV_AUTH
** GTM4WP_HARDCODED_GTM_ENV_PREVIEW - Added support for WooCommerce Grouped Products
- Added new WooCommerce option to add all order data into the data layer on the order reveived page
** This includes personal data of the customer -> you need to ensure this is used in a privacy friendly and compliant way!
** This order data will be always present on the order received page, even if the page is reloaded or later revisited! - Removed several unofficial data layer variables on the WooCommerce order received page as they can be read using the new order data option
** transactionDate
** transactionType
** transactionPaymentType
** transactionShippingMethod
** transactionPromoCode - Improved: price reporting with the WooCommerce enhanced ecommerce integration now follows the option set with the ‘Display prices in the shop’ option of WooCommerce
- Improved: from WooCommerce 3.7 WC_Abstract_Order::get_used_coupons() was replaced with WC_Abstract_Order::get_coupon_codes() which is now used if WC 3.7+ is detected
- Improved: use localStorage for WooCommerce duplicate transaction tracking prevention if available. Should be work with Safari at least for now.
- Fixed: WooCommerce duplicate transaction tracking prevention’s cookie was set to expire on session end, now adds 1 year.
- Deprecated data layer variable productIsVariable. Use the new productType data layer variable which will equal to simple, variable, grouped or external depending on the type of the product shown
- Fixed: Wrong lookup for product brand name if Use SKU instead of product ID option was turned on
- Fixed: Wrong lookup for product brand name for variable products
- Fixed: check if $woo->customer is initialized
- Fixed: no checkout step reported on WooCommerce checkout page if the user has accepted the default selection of the payment and shipping methods
! Planned deprecation of support for WooCommerce 2.x-3.1.x with next plugin version !
! Planned deprecation of support for WordPress 4.x with next plugin version !
1.10.1
- Fixed: wrong cookie name was used with the newly introduced double transaction tracking protection while setting the cookie
- Fixed: double transaction tracking JavaScript code is now only included on the order received page
- Fixed: product impressions not properly reported if Products per impressions were set to 0
- Fixed: replaced all references to AdWords to Google Ads
1.10
- Added: Automatically add the noscript part of the container code after the opening body tag for WordPress 5.2+ sites where themes support the new wp_body_open action
- Added: add associated taxonomy values for post type
- Added: select brand taxonomy for WooCommerce products to populate “Product brand” dimension in enhanced ecommerce
- Added: add cart content into data layer so that you can personalize your site experience using Google Optimize
- Added: option to remove shipping costs from revenue data on order received page of WooCommerce
- Added: if you enable either enhanced ecommerce or just Google Ads remarketing variables, 3 new data layer variables will be also available about the product on a detail page
- Product rating details (productRatingCounts)
- Average product rating (productAverageRating)
- Review count (productReviewCount)
- Added: if you are using Cloudflare, you can now add the country code HTTP header value into the data layer and read from it with the geoCloudflareCountryCode variable name
- Fixed: better compatibility with Google’s mod_pagespeed
- Fixed: missing product quantity while adding a variable product into the cart
- Fixed: prevent multiple tracking of WooCommerce orders on mobile devices where the mobile browser reloads the order received page from local cache executing GTM tracking again
1.9.2
- Fixed: possible PHP warning if geo data or weather data feature is turned on
1.9.1
- Fixed: handle out of quota cases with ipstack queries properly
- Fixed: proper YouTube tracking for WordPress sites and WordPress multisites installed in a subdirectory
- Fixed: properly detect client IP address and also properly escape this data while using it
- Fixed: WooCommerce checkout steps after page load did not include products in the cart
- Fixed: checkout step events for payment mode and shipping type not always fired
- Fixed: the CMD on Mac will be treated just like the Ctrl key on Windows while processing the product click event in the WooCommerce integration (thy for luzinis)
- Fixed: add currencyCode to every ecommerce action in WooCommerce integration
- Fixed: better WooCommere Quick View integration
- Fixed: possible cross site scripting vulnerability if site search tracking was enabled due to not properly escaped referrer url tracking
- Changed: code cleanup in WooCommerce integration
1.9
- Added: initial support for AMP plugin from Automattic (thx koconder for the contribution!)
- Added: option to remove tax from revenue data on order received page of WooCommerce
- Added: WooCommerce enhanced ecommerce datasets now include stock levels
- Added: new productIsVariable data layer variable is set to 1 on variable WooCommerce product pages
- Added: product impressions can now be split into multiple chunks to prevent data loss on large product category and site home pages (thx Tim Zook for the contribution!)
- IMPORTANT! You will need to update your GTM setup, please read the new Step 9 section of the setup tutorial page.
- Added: you can now disable flagging of WooCommerce orders as being already tracked once. In same cases (with iDeal for example) you may need this to make purchase tracking to work.
- Added: uninstalling the plugin will now remove configured plugin options from database
- Added: new advanced plugin option: data layer variable visitorDoNotTrack will include 1 if the user has set the do not track flag in his/her browser
- Added: new data layer event when a user has logged in on the frontend: gtm4wp.userLoggedIn
- Added: new data layer event when a new user has registered on the frontend: gtm4wp.userRegistered
- Added: new advanced plugin option: move data layer declaration and Google Tag Manager container as close as possible to the beginning of the HTML document
- Added: better WP Rocket support
- Updated: Full Google Optimize support. Now the plugin can load your Google Optimize container with the recommended code placement
- Updated: moved most of the inline JavaScript codes into separate .js files which should help cache plugins to do their job much better when my plugin is active
- Fixed: wrong ecomm_pagetype on product search result pages
- Fixed: PHP notice in some cases when geo data was not loaded properly
- Fixed / Added: freegeoip.net was rebranded to ipstack.com and an API key is needed now even for free usage. You can now add your API key so that weather data and geo data can be added into the data layer
- Warning: some plugin features will be remove from v1.10, most of them can be tracked now using pure Google Tag Manager triggers:
- Social actions
- Outbound link click events
- Download click events
- Email click events
- Warning: PHP 5.6 is now the minimum recommended version to use this plugin. I advise to move to PHP 7.x
1.8.1
- Added: new visitorIP data layer variable to support post-GDPR implementations where for example internal traffic exclusion has to be made inside the browser
- Fixed: JavaScript error around the variable gtm4wp_use_sku_instead
- Fixed: added _ as a valid character for gtm_auth GTM environment variable
- Fixed: corrected typo – gtm4wp.checkoutStepEEC
- Fixed: two strings were not recognized by WordPress Translate on the admin page
- Fixed: some other plugins call found_variation event of WooCommerce without product variation data being included
- Fixed: product name included variation name on order received page which broke GA product reports
- Fixed: in some cases, no contact form 7 data was being passed to the gtm4wp.contactForm7Submitted event
- Updated: added CDATA markup around container code for better DOM compatibility
- Updated: removed ‘SKU:’ prefix text from classic ecommerce dimension as it broke some enhanced ecommerce reports
1.8
- Fixed: weather data tracking codes could result in fatal PHP error
- Fixed: cart events did to fire while user pressed the Enter key in quantity fields
- Fixed: contact form 7 changed some code which prevented successful form submission tracking
- Changed: links to plugin website updated
- Changed: gtm4wp.cf7formid data layer variable now includes the ID of the form in WordPress
- Added: gtm4wp.cf7inputs includes data that has been filled in the form
- Added: WooCommerce compatibility headers
- Added: admin warning for WooCommerce 2.x users. This plugin will drop support for WooCommerce 2.x soon
- Added: postFormat data layer variable on singular pages
- Added: customer* data layer variables with stored billing and shipping data, total number of orders and total value of those orders (needs WooCommerce 3.x)
- Added: geo* data layer variables to get country, city, lat-lon coordinates of the visitor
- Added: visitorUsername data layer variable with the username of the logged in user
- Added: more detailed checkout reporting for WooCommerce sites
- Add gtm4wp.checkoutStepEEC to your Ecommerce Helper trigger
- Change a typo: gtm4wp.checkoutOptionECC => gtm4wp.checkoutOptionEEC
- Added: option to include full product category path in enhanced ecommerce reporting (can cause performance issues on large sites!)
- Added: initial support for Google Tag Manager Environments
- Added: support for WooCommerce Quick View plugin
- Updated: description of code placement options to clarify what this option does
- Updated: cleanup of readme.txt, spelling and grammar improvements
- Updated: bundled WhichBrowser lib v2.0.32
1.7.2
- Fixed: in some cases, the remove item from cart link in a WooCommerce cart was not altered properly with additional tracking codes
- Fixed: product categories were empty in the cart, on the checkout pages and on the order received page for product variations
- Fixed: checkout option data included checkout step #1 if cart page was setup to be the first
- Fixed: even more WooCommerce 3.x compatibility
- Added: registration date of the logged in user can be added to the data layer
- Updated: geoplugin.net has been replaced by freegeoip.net for weather tracking which has far better quota for free usage
- Updated: Google Ads dynamic remarketing data layer items on a WooCommerce product page will be shown for the root product as well on variable product pages
- Updated: Selecting a product variation will include the price of the product in Google Ads dynamic remarketing data layer items
- Updated: minor code cleanup
1.7.1
- Fixed: PHP 5.3 compatible syntax in frontend.php
- Fixed: PHP error using classic ecommerce with WooCommerce 2.6.x
- Updated: Added data-cfasync=’false’ to all elements to prevent CloudFlare to load scripts async
- Added: Warning for users of PHP 5.4 or older to consider upgrade (FYI: PHP 5.5 and older versions do not get even security fixes)
1.7
- Updated: even better WooCommerce 3.0 compatibility (WooCommerce 2.6 still supported but this support ends with the next plugin version)
- Fixed: properly escaping product category name on variable product detail pages
- …