-
Notifications
You must be signed in to change notification settings - Fork 288
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
feat: Add Segment tracking for Product List Viewed and Product Clicked events #121
Conversation
Simplify HOC implementation
- Add product clicked event examples - Update other examples with prop type definitions - Update titles of other examples
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.
Can you clarify how the category
field is filled?
It seems to fill differently at different times. Sometimes, if I'm on a second-level tag, it still fills with the primary tag (i.e I clicked in from Tag D -> Tag D-2
, but Tag D
is what shows in the category field inside Segment), sometimes the opposite (i.e I clicked in from Tag D
, but Tag D -> Tag D-2
is what shows in the category field inside Segment).
It doesn't matter if I click from a Tag page, or the default grid page, the category
is always filled differently.
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.
When visiting the default grid homepage, I do not see the Product List Viewed
tracking event fire.
However, when I visit from a tag page, I see the event first twice. Once, correctly, it fires with the products that are attached to that tag, and then once, incorrectly, it fires with ALL products in my shop.
Is it possible you have both events attached to the tag
page, and one should be moved to the default grid?
list_id: "", | ||
|
||
// Name of tag or Home | ||
category: "", |
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.
Product list viewed
does not seem to be getting the category
data, it's always blank, no matter which list I'm on.
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.
@kieckhafer I'm getting the category when I visit a tag page
); | ||
} | ||
export default (options) => track(({ tag, catalogItems }) => { | ||
const products = (Array.isArray(catalogItems) && catalogItems.map((catalogItem) => catalogItem.node.product)) || undefined; |
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.
Do we need a protection here to check for node
, similar to the other Segment PR? We might not, I haven't had any errors yet.
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 don't think so, because node should exist if there are items in the array.
@kieckhafer The category fields just take the first tag from the product. Since we have no real weight mechanic, I figured the first tag must be the most imported, regardless of the page it's on. So, even a tag page, the category will still be the first tag for that product. The |
@kieckhafer I'm not sure, but the multiple renders may be related to |
@kieckhafer added a ticket about the multiple re-renders / multiple tracking events dispatched. #142 |
Looks good with the changes, and the new ticket added to fix the issue. 👍 |
Issue: #56
Impact: minor
Type: feat
Issue
Add event tracking for
Product List Viewed
andProduct Clicked
event for the homepage and tag pages.Solution
lib/tracking/trackProductListViewed.js
to include outlined data mappingsProduct List Viewed
is triggered when viewing the homepage and tag pagesTesting
.env
(see.env.example
)sources > javascript > debugger
see the event being tracked with proper data mappingsYou should see a
Product List Viewed
, andProduct Clicked
events something like the following examples:Note: The mappings are not going to be 100% the same as segments suggestions.