Google Analytics: Add remaining enhanced eCommerce trackers#8218
Google Analytics: Add remaining enhanced eCommerce trackers#8218dereksmart merged 15 commits intomasterfrom
Conversation
|
@allendav For the |
I saw data come in the following two places:
|
emdashcodes
left a comment
There was a problem hiding this comment.
I have two questions and I am having an issue with the remove from cart event (#8218 (comment)). Otherwise, everything else seems to be testing nicely now and I see data coming into GA.
| } | ||
|
|
||
| $item_details = array( | ||
| 'id' => $product->get_id(), |
There was a problem hiding this comment.
Should this be sku or id like the other entries?
There was a problem hiding this comment.
I was wondering about that too - I'll make it consistent
| $selector = ".products .post-" . esc_js( $product->get_id() ) . " a"; | ||
|
|
||
| $item_details = array( | ||
| 'id' => $product->get_id(), |
There was a problem hiding this comment.
Should this be sku or id like the other entries?
|
@justinshreve wrote:
Hmmm - I'll take a look edit: OK - I can reproduce this as well. When the first item is removed, core WooCommerce refreshes the cart display. When this happens, the jQuery added event handler for GA for a.remove gets lost. Not sure how to fix yet - this could be tricky - might need to let it bubble up to a container and listen there or something edit: edit: Fixed in a1e5730 To verify it is working properly, add the following to
|
|
@justinshreve - all items, including the remove-from-cart business, fixed and ready for re-review |
emdashcodes
left a comment
There was a problem hiding this comment.
Looking good from my end. Everything is testing correctly.
jeherve
left a comment
There was a problem hiding this comment.
Just a quick note to help with our documentation.
| $cart = WC()->cart->get_cart(); | ||
|
|
||
| foreach ( $cart as $cart_item_key => $cart_item ) { | ||
| $product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); |
There was a problem hiding this comment.
Could you add a docblock here so as to not trip the parser? Since it's a Woocommerce filter something like /** This filter is already documented in xxxx.php */ would do the trick.
5977a8b to
4a1eee3
Compare
unneeded jquery nesting
anchors that can get re-rendered
4a1eee3 to
8688b65
Compare
Fixes #8181
Changes proposed in this Pull Request:
Adds support for the following Enhanced eCommerce tracking events:
Remove item from cart
Track product impressions
Track product listing clicks
Track product detail views
Track checkout started
Testing instructions:
Remove From Cart
In your Google Analytics Dashboard ( https://analytics.google.com/ ), go to Admin for your site (it looks like a gear in the lower left corner)
Under View select Ecommerce Settings
Enable Ecommerce AND Enhanced eCommerce if you haven't already.
Add the SKU-less product and the SKU'd product to the cart
Navigate to cart view
View the source for the page
Search for "ec:" - ensure javascript is enqueued for both products
Open the JavaScript dev console
Click on the remove for each product in turn
Ensure no JavaScript errors appear in the console
Wait a few minutes
In your Google Analytics Dashboard, go to Real-time and then Events
Make sure you see the remove from cart events for the SKU-less and the SKU'd product (you might need to click on the UX category to see them)
Product Impressions
Product Clicks
Product Detail View
Checkout Initiated
Ensure no JavaScript errors appear in the console
Wait a few minutes
In your Google Analytics Dashboard, go to ??? (I couldn't find where this ends up - do you know @justinshreve ?)
Lastly, disable WooCommerce
Make sure with a tracker ID enabled, and all settings INCLUDING enhanced ecommerce enabled, that you are able to navigate the site without PHP errors
Make sure with a tracker ID enabled, and all settings EXCEPT enhanced ecommerce enabled, that you are able to navigate the site without PHP errors