duracelltomi / gtm4wp Goto Github PK
View Code? Open in Web Editor NEWGoogle Tag Manager plugin for WordPress
Home Page: https://gtm4wp.com/
License: GNU General Public License v3.0
Google Tag Manager plugin for WordPress
Home Page: https://gtm4wp.com/
License: GNU General Public License v3.0
https://developers.google.com/optimize/#the_page-hiding_snippet_code
This code has to be placed above the GTM container snippet thus it can not be fired from inside GTM. Plugin should include an option to add this code.
We have been pointed out that some of our customers were having issues with our shop. They weren't able to open products from the category pages.
When investigating it turns out that they were using an AdBlocker (AdGuard - Chrome - MacOS) and had set several filters to also block GTM.
With the Enhanced E-Commerce Option enabled the productClick event causes a major failure:
The preventDefault() disables the normal redirect and with GTM blocked by the user, the manual redirect that is implemented in the eventCallback is never triggered.
https://github.com/duracelltomi/gtm4wp/blob/master/integration/woocommerce.php#L721
Why do we use a manual redirect at all? What's the idea behind the preventDefault() here and why do we differentiate between a normal click and one with ctrl-key pressed? In my tests the Event is fired in any case also with the preventDefault and eventCallback removed. Am I missing something?
In any case this implementation should be addressed. We need a fallback if GTM is blocked.
A while ago I asked if you could add user emails and usernames as dataLayer variables in issue #9 , You did so very quickly and I am very grateful. We use to define that manually and build our remarketing tag by referencing each datalayer variable we needed. It recently came to my attention that I can just call the google_tag_params hierarchy and receive all the values. Unforchantly in doing so, I noticed a small issue. The email and username are included within the google_tag_params: { }. It should be defined outside of that to avoid being invoked by the adwords remarketing script while allowing me to manually define it as a data layer variable for a range of other tags.
Emails should only be used for services offering customer matching, like Active Campaign JS User Cookies setting, Facebook Custom Match Pixel, Adroll Customer Match Pixel but not for Google services. Currently, the visitorType and visitorEmail are within the google_tag_params hierarchy, which means when you define the dataLayer v2 variable "google_tag_params" in Tag Manager and link it to the built in Adwords Remarketing Tag w/ datalayer matching, it will pull everything within thegoogle_tag_param.
This creates a breach of the Google Adwords remarketing terms and conditions as you mentioned. Since using the google_tag_params is the proper method for remarketing, this is not ok.
The solution is to keep the personal tags, visitorType and visitorEmail, outside of the google_tag_param. The current setup would allow me to remarketing to people directly using their emails, which is a No no. If you just moved these two dataLayer variables into independent hierarchies, this would be solved easily.
I have attached some screenshots to better explain what I did and why it can be a problem for some users. Short term solution is going back and manually defining all these attributes as variables then calling them in the remarketing tag, but when working on a lot of new clients that can be very time-consuming. For the average user following a tutorial, this would be overlooked and quickly cause then issues.
I just wanna note again, this feature is critical to many newer attribution solutions and web tracking automational software. It should not be removed, just relocated.
Image of tag setup that causes this issue
Example of Proper Use case outside of the google_tag_params and defined as a seperate dataLayer variable
Example of Proper Use case outside of the google_tag_params and defined as a seperate dataLayer variable
On the cart page if the user presses enter in a quantity field, cart events are not being fired.
Possible workaround: listen to form submit instead of Update Cart button click.
Although looping through the full category tree to pass this in enhanced ecommerce can cause performance issues on larger sites, there are cases where this is useful and acceptable. To prevent performance issues, there could be a new option under the WooCommerce integration that would allow users to turn on full category path in the data layer instead of the name of the lowest level category:
https://wordpress.org/support/topic/woocommerce-parent-category-not-parsing/
It would be awesome to have the word count in the data layer when the page loads. Even more useful could be "Range of word count", possible values:
I would later pass these values as custom dimensions with pageview hits and then see which word count is the most correlating with content engagement, newsletter signups, etc.
Please see attached ZIP file.
This is regarding AMP – CloudFlare.com – AMPforWP.com
More info at:
GIThub
ahmedkaludi/accelerated-mobile-pages#958
WordPress support AMPforWP.com
https://wordpress.org/support/topic/gtm-google-tag-manager-error-http-response-code-indicates-tag-failed-to-fire-s/
Trying to make Google Tag Manager work correctly with CloudFlare and AMPforWP.com using "DuracellTomi's Google Tag Manager for WordPress"
Ref: WordPress support DuracellTomi's
https://wordpress.org/support/topic/setting-gtm-for-amp-pages/
Attached is a PHP file / WordPress plugin that will place the GTM - Google Tag Manager - code in the correct place in AMPforWP.com
Hope this will make it easier to develp DuracellTomi's Google Tag Manager for WordPress to support AMP through AMPforWP.com
Currently the "Use SKUs instead of product IDs" option only changes what is being reported in the AdWords dynamic remarketing variables. This should be changed so that classic and enhanced ecommerce reports also use SKUs if plugin user selected that option.
Originally posted:
https://wordpress.org/support/topic/postid-is-set-on-category-pages/
When I check “Post ID”, the postID it is also included on category pages. The category page gets the postID of the last post. That’s not what I intended. I would like to have that only post pages return a post ID.
Is there a function to return the Google Tag Manager ID? I need to use the ID in another plugin and I'd like to use a built-in function if available.
Hi, I just fund a problem with feature that change ID to SKU. On simple products on event: gtm4wp.addProductToCartEEC information which is pushed to dataLayer contains something like: id: 'SKU: 10001', and it should be id:'10001' without SKU. When do this changes:
Line 718: "sku" => $product_sku,
Deleted: ? __( 'SKU:', 'duracelltomi-google-tag-manager' ) . ' ' . $product_sku : $product_id,
Orginal: "sku" => $product_sku ? __( 'SKU:', 'duracelltomi-google-tag-manager' ) . ' ' . $product_sku : $product_id,
And now this is working. Maybe you should make this changes in plugin, but I am not sure what is was for ? __( 'SKU:', 'duracelltomi-google-tag-manager' ) . ' ' . $product_sku : $product_id, and what could happen more when I deleted this.
There are cases where only orders with completed payments should be tracked into GA.
For this case, some enhancement should be added:
Original discussion:
#35
https://wordpress.org/support/topic/product-variations-not-in-data-layer/#post-9001026
Would it be possible to add the prefix “woocommerce_gpf” to the product id’s? My current product feed plugin [Google Product Feed plugin from WooThemes] does it this way.
Currently all media player trackers are loading on every page once you enabled the option in plugin. This loads for example the YT player API on each page, even of you only have one video somewhere.
The code needs to be improved so that it can detect whether external libraries are needed to be loaded.
The URLs inserted by this plugin are relative, i.e., //www.googletagmanager.com/gtm.js.
It would be better to make the URLs explicitly HTTPS instead, i.e., https://www.googletagmanager.com/gtm.js.
See https://jeremywagner.me/blog/stop-using-the-protocol-relative-url/ for an explanation of the benefits of using explicit HTTPS URLs (and the drawbacks of using relative URLs).
Hey Tom, I'd love to see stock levels exposed via dataLayer so I can pull into Analytics as custom dimension. Past companies had issues keeping products in stock and would no react to the issue until I put together overwhelming analytics on lost sales.
Now that GDPR takes place 25th of May, It should be able for the user to Opt in and Opt out of tracking via the plugin.
User email doesnt print, I tried to add it but its not working
false isue
https://wordpress.org/support/topic/suggestion-add-additional-weather-api/
The openweathermap api returns limited data compared to other weather services. Feel-like Temp, Dew Point, and UV Index are some of the more important pieces of data they are missing.
Can I suggest adding Dark Sky API? They’ve been around for a long time. It’s one of the best weather api’s available. They offer many more data points. The first 1000 calls per day are free.
https://darksky.net/dev/docs
There are cases when a media player is showed in a popup layer which is created while clicking on an activation link. In those cases the DOM does not include the media player element on page load thus there will not be data layer events for players in such popups.
There is browser feature that could help the plugin to detect DOM changes but this is not supported in IE10 and earlier and according to MDN, Safari implements it as an experimental feature:
https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
there's an issue that's well described in magento/magento2#10857 that affects this plugin too. Please let me know if I can be of any more help with resolving this.
The code is found around here:
gtm4wp/integration/woocommerce.php
Line 380 in 18793b3
Use case: Mixpanel could use this info:
mixpanel.identify("{{visitorId}}");
mixpanel.people.set({
"$first_name": “Foo",
"$last_name": “Bar",
"$created": "2013-04-01T09:02:00",
"$email": “[email protected]”,
“$phone”:”555-55555"
});
When removing a product from the cart a notice is displayed by WooCommerce with a link to undo the change and add the product back to the cart. When clicking on this link it would be great if the addToCart event would fire again.
wondered if it would be easy to add users location to the datalayer, i know you’re already using it for the weather tracking (which is super awesome in itself), just seems like it be crazy useful to be able to access the location for custom tags too.
Hi there... just a thought to add an option to enable click events of phone numbers (based on href tel) as an addition to the click tracking on email addresses.
Thanks!
Since WooCommerce 3.x is now the latest version and the plugin seems to meet all the new requirements, it is time to inform users of WooCommerce 2.6 or older to upgrade and to prepare for the drop of support for those WooCommerce version.
v1.8 will still support 2.6- but should include a dismissable message
v1.9 will drop compatibility codes from the source
Product ID with the remarketing tag is being enclosed in brackets, it should not be enclosed in anything for correct matching with Google Merchant Feed
With GDPR it might be not possible to send full IP address into GA
This means that users will need to filter internal traffic inside GTM.
To be able to do so, the IP address has to be added into the dataLayer
Product click event handler needs to check whether clicked link's href attribute points to the product detail page so that links pointing to other targets (like brand page) can still work:
http://www.etraper.pl/kategoria-produktu/odziez/meska/kurtki/
Clicks on products in product list pages are blocked by plugin if GTM is not loaded because of an ad blocker. Click event handler should check whether GTM was actually loaded and only act if yes.
https://codex.wordpress.org/Function_Reference/get_post_format
$format = get_post_format() ? : 'standard';
Should be a separate checkbox in plugin option
Most event handlers are currently added as inline JavaScript codes into the WordPress site. This makes the size of the loaded page larger and can prevent certain cache plugins to fully boost performance on pages.
The plugin could change the behavior of attaching event handlers using jQuery selectors by creating a separate .js file where most event handlers could be defined as functions and WooCommerce/WordPress hooks could be used to add click events directly to the buttons and links.
This would also make the WooCommerce integration more compatible with themes where the standard WooCommerce HTML coding has been abandoned.
Originally posted here:
https://wordpress.org/support/topic/exclude-some-datalayer/
Some users would like to include the cart page as step 1 in the checkout funnel. Although this is usually not the intened use of checkout steps in enhanced ecommerce, it could be easy to add an option and let users decide how the implementation should work
According to the readme file, it states that "the most important part of the GTM codes" is inside the and that this is the iframe part of the code and also that it only fires when javascript is broken/disabled. This does not sound right: Is this not the other way around:
head
- this is the javascript portion without an iframe right?
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-WCRQ6CV');</script>
<!-- End Google Tag Manager -->
body
- clearly this is the iframe part meant for disabled javascript
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-WCRQ6CV"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
I would like to be able to push the WP username to the dataLayer as opposed to the user's email address. Just wondering if possible to include in the future..?
Thanks!
I nice enhancement for the plugin would be if there was an Easy Digital Downloads integration.
It could track sales, cart checkouts, etc.
A filter should be added into the WooCommerce implementation so that people can add their own price calculations.
Most probably this would be useful if the filter would add the whole product array so that custom dimensions can be added easily as well.
Docs here:
https://wistia.com/doc/player-api
Hi there!
Im getting a PHP notice in the current version of gtm4wp in line
https://github.com/duracelltomi/gtm4wp/blob/master/admin/admin.php#L887
"( ! ) Notice: Undefined index: plugintocheck in /wp-content/plugins/google-tag-manager/admin/admin.php on line 887"
My solution would be to set plugintocheck to NULL which would not break the current code:
"plugintocheck" => isset($fielddata["plugintocheck"]) ? $fielddata["plugintocheck"] : null
According to Googles documentation the implementation of the "measuring views on product details" is missing the enclosing "products" under "detail" in the "gtm4wp.changeDetailViewEEC" event.
Currently the data is written directly into the "detail" element.
See: https://developers.google.com/tag-manager/enhanced-ecommerce
And: https://github.com/duracelltomi/gtm4wp/blob/master/integration/woocommerce.php#L115
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.