Skip to content
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

Merged
merged 46 commits into from
Jun 13, 2018

Conversation

mikemurray
Copy link
Member

@mikemurray mikemurray commented Jun 5, 2018

Issue: #56
Impact: minor
Type: feat

Issue

Add event tracking for Product List Viewed and Product Clicked event for the homepage and tag pages.

Solution

  • Add docs outlining data mappings
  • Update lib/tracking/trackProductListViewed.js to include outlined data mappings
  • Add HOC for tracking product clicked event
  • Ensure the Product List Viewed is triggered when viewing the homepage and tag pages

Testing

  1. Create a segment account and get the API key. Add the key to the .env (see .env.example)
  2. Start the app navigate to the Product grid homepage and tag pages
  3. In the segment dashboard under sources > javascript > debugger see the event being tracked with proper data mappings

You should see a Product List Viewed, and Product Clicked events something like the following examples:

Note: The mappings are not going to be 100% the same as segments suggestions.

@mikemurray mikemurray changed the title [WIP] feat: Add Segment tracking for Product List Viewed feat: Add Segment tracking for Product List Viewed Jun 11, 2018
@mikemurray mikemurray changed the title feat: Add Segment tracking for Product List Viewed feat: Add Segment tracking for Product List Viewed and Product Clicked events Jun 11, 2018
Copy link
Member

@kieckhafer kieckhafer left a 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.

Copy link
Member

@kieckhafer kieckhafer left a 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: "",
Copy link
Member

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.

Copy link
Member Author

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

screen shot 2018-06-12 at 11 01 32 am

);
}
export default (options) => track(({ tag, catalogItems }) => {
const products = (Array.isArray(catalogItems) && catalogItems.map((catalogItem) => catalogItem.node.product)) || undefined;
Copy link
Member

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.

Copy link
Member Author

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.

@mikemurray
Copy link
Member Author

@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 list_id is better served to identify what page these related products belong to.

@mikemurray
Copy link
Member Author

@kieckhafer I'm not sure, but the multiple renders may be related to withTag and withCatalogItems. The component renders exactly twice, and my assumption is that both are doing a graphql query and that makes the component render twice.

@mikemurray
Copy link
Member Author

@kieckhafer added a ticket about the multiple re-renders / multiple tracking events dispatched. #142

@kieckhafer
Copy link
Member

Looks good with the changes, and the new ticket added to fix the issue.

👍

@kieckhafer kieckhafer closed this Jun 13, 2018
@kieckhafer kieckhafer reopened this Jun 13, 2018
@kieckhafer kieckhafer merged commit 8da597e into master Jun 13, 2018
@kieckhafer kieckhafer deleted the feat-56-mikemurray-segment-grid branch June 13, 2018 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants