-
Notifications
You must be signed in to change notification settings - Fork 800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Google Analytics: Add support for universal analytics for eCommerce #8182
Conversation
@allendav While testing the purchase event, I noticed that my two categories came through as one in GA (for legacy/ga.js and universal):
|
Everything else seems to be testing nicely 👍 . |
@justinshreve wrote:
That's by design. We concatenate the categories on purpose. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving from my end of things. Everything tests correctly and changes are looking good to me.
$track['code'] = 'search'; | ||
private function __construct() { | ||
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { | ||
error_log( print_r( Jetpack_Google_Analytics_Options::debug_dump(), true ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this error_log
needed?, I'm seeing it's only dumping empty arrays even when nothing remarkable happens.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its just for when WP_DEBUG is active. It isn't as useful as I'd thought - I think I'll just delete the call and the method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed in dca8278
I've tested following the test instructions and when adding products to the cart when With these settings: Also I didn't get to see anything about my checkout when looking at Realt Time -> Conversions I may have tested something wrong. I do see The testing instructions when tried with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed and couldn't reproduce the expected view in Google Analytics dashboard. Also, left an observation on the code about an error_log
in a class constructor
@oskosk wrote:
I'll double check - I found it challenging to find the correct click sequence in the Google Analytics dashboard to surface the data myself - will carefully repeat the sequence today and post it |
Thank you @allendav! All in all, everything here looks great. Old analytics work as expected. New ones are still logged apparently. (It's just that I couldn't see the product details in Analytics' dashboard as the Testing Instructions specifically mention as something to check). This PR can be probably tested better when we launch the beta, so let's try to merge it on Monday. I do maintain my opinion on the |
@oskosk : OK, here's the secret sauce to see add-to-cart details: Edit: Again, although events are real-time, I find it can take a few minutes for data to appear under conversions |
@oskosk - secret sauce for seeing details about your checkout |
@oskosk wrote:
You're welcome!
That sounds awesome - hope we can merge #8198 and #8218 as well
Sounds good. I removed the debugging - it was useful early in refactoring the module, but not very helpful now. And yep - we'll exercise this in the beta and see if anything precipitates. |
@justinshreve - re #8182 (comment) what would you think about filtering in another |
Requested changes have been provided. Testing again now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the detailed diagrams on how to see the events. I got to see everything as expected. LGTM!
@allendav while having this branch checked out, I deactivated WooCommerce and got to see this in
Do you think it's something related to the PR or just the fact that I deactivated Woo after having created products ? |
@oskosk wrote:
...
It's an old core Wordpress bug - woocommerce/woocommerce#10777 https://core.trac.wordpress.org/ticket/36208 |
That sounds good to me. That's definitely an improvement. |
* Changelog 5.6: create base for changelog. * Update changelog with 5.5.1 info. * Changelog: add #7930 and #8238 * Changelog: add #8076 * Changelog: add #8100 * Changelog: add #8117 * Changelog: add #8141 * Changelog: add #8143 * Changelog: add #8147 * Changelog: add #8149 * Changelog: add #8153 * Changelog: add #8173 * Changelog: add #8184 * Changelog: add #8196 * Changelog: add #8199 * Changelog: add #8093 * Changelog: add #8171 * Changelog: add #8182 * Changelog: add #8202, #8222 * Changelog: add #8228 * Changelog: add #8240 * Changelog: add #8251 * remove AL card change
Ready to test.
Fixes #8181
Background:
The Jetpack Google Analytics module currently only supports "legacy" (ga.js) analytics
This PR refactors the module in Jetpack to add support for "universal" (analytics.js) analytics and the ecommerce plugin while maintaining support for legacy analytics.
Which is used is driven by a new field in the jetpack_wga option:
enh_ec_tracking
Both "modes" support IP anonymization, tracking new orders and tracking when products are added to the cart (on single or loop pages)
A follow-on PR will expand on this PR further by adding support for these additional enhanced analytics behaviors:
enh_ec_track_remove_from_cart
enh_ec_track_prod_impression
enh_ec_track_prod_click
enh_ec_track_prod_detail_view
enh_ec_track_checkout_started
Changes proposed in this Pull Request:
wp-google-analytics.php
file was copied tomodules/google-analytics/classes/wp-google-analytics-legacy.php
with minor editing.wp-google-analytics.php
file was then modified to either load that legacy implementation or the new universal analytics implementation.classes/wp-google-analytics-options.php
file was also added to provide a consistent interface to options for both implementations, including the following new enh_ec_tracking (on/off) flagTesting instructions:
Visit either product page.
View the source and 1) ensure the Google Analytics script (ga.js) is never referenced and 2) no jQuery is present to hook .single_add_to_cart_button or .add_to_cart_button
Elements.
Note: You should see this in the page source (for legacy/classic analytics only):
Use the helper plugin (wp-admin > Tools > Jetpack Google Analytics Helper) to set the following:
Visit either product page.
View the source and 1) ensure the Google Analytics script (ga.js) is present, 2) that the Tracking ID is present, but 3) that no jQuery is present to hook .single_add_to_cart_button or .add_to_cart_button elements.
Use the helper plugin (wp-admin > Tools > Jetpack Google Analytics Helper) to set the following:
For universal:
Back on your test site, Complete the purchase of one of each product using a gateway like Check Payment.
Return to your Google Analytics Dashboard and go to Conversions and then Ecommerce
Set the date range to today
Make sure you see the sale and that the details are correct (note: it can take a few minutes for the transaction to appear in GA)
Use the helper plugin (wp-admin > Tools > Jetpack Google Analytics Helper) to set the following:
Proposed changelog entry for your changes:
See also:
cc @justinshreve