Skip to content

track additional browse events in posthog #2011

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

Merged
merged 7 commits into from
Feb 5, 2025

Conversation

gumaerc
Copy link
Contributor

@gumaerc gumaerc commented Feb 5, 2025

What are the relevant tickets?

Closes https://github.com/mitodl/hq/issues/6624

Description (What does it do?)

This PR corrects some Posthog tracking behavior in relation to the "browse" workflow on the site, more specifically regarding topics / subtopics / related topics.

How can this be tested?

  • Make sure you have Posthog configured and pointing at your own custom project
  • Open a tab with your Posthog activity dashboard
  • Open another tab and visit the homepage at http://localhost:8062/
  • Click the "Topic" link in "or browse by Topic" below the home page search
  • Check your Posthog activity and verify that you see a clicked_hero_browse_topics event
  • Return to the homepage and scroll down to the "Browse by Topic" section
  • Click one of the topic buttons
  • Check Posthog and verify you see a topic_clicked event
  • Return to the homepage and scroll back down to the "Browse by Topic" section again
  • Click the "See All" link
  • Check Posthog and verify that you see a home_see_all_topics_clicked event
  • Now on the topics listing page, click a top level topic
  • Check Posthog and verify that you see a topic_clicked event
  • Return back to the topics listing page and click one of the subtopic pills
  • Check Posthog and verify that you see a subtopic_clicked event
  • Return back to the topics listing page and click one of the top level topics
  • On the topic channel page, you should see a "Subtopics" section, click one
  • Check Posthog and verify that you see a subtopic_clicked event
  • On the subtopic channel page, you should see a "Related Topics" section, click one
  • Check Posthog and verify that you see a related_topic_clicked event

@gumaerc gumaerc added Needs Review An open Pull Request that is ready for review and removed Work in Progress labels Feb 5, 2025
@shanbady shanbady self-requested a review February 5, 2025 19:00
@@ -119,6 +121,11 @@ const BrowseTopicsSection: React.FC = () => {
<TopicBox
key={id}
href={channelUrl ? new URL(channelUrl!).pathname : ""}
onClick={() => {
if (process.env.NEXT_PUBLIC_POSTHOG_API_KEY) {
posthog.capture("home_topic_clicked", { topic: name })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something to consider - we have a bunch of these bare event strings. it might be good to have them defined as constants somewhere so its easier to track and change

Copy link
Contributor

@shanbady shanbady left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worked when i tested it. received all the events. left minor non-blocking suggestion

@shanbady shanbady added Waiting on author and removed Needs Review An open Pull Request that is ready for review labels Feb 5, 2025
@gumaerc gumaerc merged commit d185a7a into main Feb 5, 2025
11 checks passed
@odlbot odlbot mentioned this pull request Feb 6, 2025
4 tasks
@rhysyngsun rhysyngsun deleted the cg/posthog-browse-tracking-take-2 branch February 7, 2025 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants