-
Notifications
You must be signed in to change notification settings - Fork 70
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
Update tracking for blocks #311
Update tracking for blocks #311
Conversation
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 the code tested locally.
My only concern is the price data type.
Other than that, LGTM.
} ); | ||
if ( products.length > 0 ) { | ||
trackEvent( 'view_item_list', { | ||
item_list_id: 'engagement', |
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.
📜 💅
If I understand the docs correctly, this id is to identify the list from which we're reporting.
With blocks, we can have multiple lists on different pages. But currently, we send engagement
regardless of which list we track. Maybe we could somehow forward the block instance id, or at least page ID?
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.
That would be a nice addition! I've opened issue #324 so as to not get off track in this PR.
value: formatPrice( | ||
storeCart.totals.total_price, | ||
storeCart.totals.currency_minor_unit | ||
), |
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.
Documentation states it should be a number
, we send a string
.
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.
Nice catch! Updated in 4a06f52
assets/js/src/tracking.js
Outdated
storeCart.totals.total_price, | ||
storeCart.totals.currency_minor_unit | ||
), | ||
coupon: storeCart.coupons[ 0 ]?.code || '', |
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.
❔
I wonder if the empty ""
in case of lack of coupon is the most accurate representation. Shouldn't we just don't send this property in case of lack of coupon? I'm not sure how the value being set (event to empty string) would be interpreted.
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.
That's a good point. I'm not sure what the behavior would be and from a quick search I couldn't find any thing in the GA documentation about it 🤔 I've updated how it works in 813b7ee so we're not including an empty string.
Changes proposed in this Pull Request:
Closes #268
Tracking for blocks only supports Universal Analytics as it currently stands. This PR updates the tracking for GA4 and removes references to UA documentation.
Screenshots:
Detailed test instructions:
view_item_list
All Products
block and view page in incognito with GA Debug enabled (Alternatively use Tag Assistant to monitor events)view_item_list
event is triggered with the correct parametersview_item_list
is triggered and that it matches the above data structure.add_to_cart
All Products
page, clickAdd to cart
for a productadd_to_cart
event is triggered with the correct parametersremove_from_cart
andchange_cart_quantity
remove_from_cart
event to work. Issue with tracking quantity changes in cart #312 has been opened so that this can be addressed in a follow-up PR.begin_checkout
Note: The
experimental__woocommerce_blocks-checkout-render-checkout-form
hook which thebegin_checkout
event relies on doesn't currently work. Reported in woocommerce/woocommerce-blocks#11472.begin_checkout
event is triggered with the correct parameters and that item quantities and coupon name are correct in the event dataadd_shipping_info
Place Order
add_shipping_info
event is triggered with the correct parametersselect_content
All Products
blockselect_content
event is triggered with the correct parameterssearch
Changelog entry