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: create experiment from a funnel #27473

Merged
merged 40 commits into from
Jan 29, 2025
Merged

Conversation

joshsny
Copy link
Contributor

@joshsny joshsny commented Jan 13, 2025

Problem

If a user creates an insight to track a metric, it's likely they want to improve that metric if they can. This supports creating an experiment from an insight. Right now we surface this option for a funnel only, and will track engagement.

Changes

  • Add a create experiment button to an insight if it can be mapped to an experiment metric directly
  • Prefill the metric when creating the experiment

Loom: https://www.loom.com/share/ba32c35e3a794e08ab35eb28f8a80e56

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Does this work well for both Cloud and self-hosted?

Yes

How did you test this code?

Tested for 3 scenarios:

  • Creating from a funnels query
  • Check button does not show for an invalid query
  • Test an insight that fails to load
  • Test an insight that has an incorrect metric for experiments
  • Edit all fields that are changeable from the insight page to see that they map to the experiment

@joshsny joshsny self-assigned this Jan 13, 2025
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

99 snapshot changes in total. 0 added, 99 modified, 0 deleted:

Triggered by this commit.

👉 Review this PR's diff of snapshots.

Copy link
Contributor

github-actions bot commented Jan 13, 2025

Size Change: +33 B (0%)

Total Size: 1.16 MB

ℹ️ View Unchanged
Filename Size Change
frontend/dist/toolbar.js 1.16 MB +33 B (0%)

compressed-size-action

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

97 snapshot changes in total. 0 added, 97 modified, 0 deleted:

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@joshsny joshsny marked this pull request as ready for review January 16, 2025 21:56
@joshsny joshsny requested review from jurajmajerik and a team January 16, 2025 22:06
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

28 snapshot changes in total. 0 added, 28 modified, 0 deleted:

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@joshsny
Copy link
Contributor Author

joshsny commented Jan 17, 2025

@jurajmajerik I've stripped out any properties that aren't currently available in the experiments UI to avoid a situation where the user can't change the metric

Copy link
Contributor

@jurajmajerik jurajmajerik left a comment

Choose a reason for hiding this comment

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

Cool feature, thanks for taking this on! 🙂 A few things to address:

@jurajmajerik
Copy link
Contributor

jurajmajerik commented Jan 17, 2025

General feedback: when adding a UI feature, please add screenshots and/or a Loom, makes it much easier to see how the thing should be tested.

@jurajmajerik
Copy link
Contributor

jurajmajerik commented Jan 17, 2025

Right now we surface this option for a funnel only, and will track engagement.

Why not add it for both right away? The code to do this is already there, so should be straightforward.

Also, I see that you tested for the Trends option too?

  • Creating from a trends query

@jurajmajerik
Copy link
Contributor

Currently the insight value is null for me when navigating to the form from an insight. As a result, the desired metric doesn't get populated. The issue seems to be that somehow, the insight ID doesn't end up in the URL, from which it should be retrieved.

IMO, whenever the intention is to create an experiment from an insight, but we fail to load the insight, we should throw. Otherwise the experiment gets saved without the metric which is poor user experience.

image

@jurajmajerik
Copy link
Contributor

image

I personally like the position of this button, as it's prominent and will likely drive adoption for experiments. But I'd check with @PostHog/team-product-analytics if it's a good idea to put it there. Perhaps the intent of this panel is to only show properties related to the chart, so better to double check with them.

@joshsny joshsny requested a review from jurajmajerik January 17, 2025 21:40
@joshsny
Copy link
Contributor Author

joshsny commented Jan 17, 2025

@jurajmajerik Addressed your comments here, thanks for these. Also added a Loom showing functionality locally: loom.com/share/ba32c35e3a794e08ab35eb28f8a80e56

@jurajmajerik
Copy link
Contributor

Thanks @joshsny, working great! A few more comments:

  • Great idea auto-populating the experiment name
  • I really think the "Run experiment" option should be always visible in an insight, not just when the insight is saved. As a user, I personally don't save Insights that often. But I might want to run an experiment on them regardless.
  • Please add a tooltip to the "Run experiment" button explaining what it does (e.g. "open the experiment creation form where the metric is already prepopulated").
  • When creating an experiment from an insight, it might be worth adding an info banner at the top of the experiment form. It's not super clear when/how the metric gets added to the experiment. There's no indication of the metric itself in the experiment form. So a banner explaining "please fill in these fields, click save and the experiment with your metric will be created" would be great.
  • Are you planning to add the usage event too?

Copy link
Contributor

@zlwaterfield zlwaterfield left a comment

Choose a reason for hiding this comment

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

Awesome, this looks great :)

I'll fall to @jurajmajerik for approval - I like his suggestions for the tooltip and banner :)

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

4 snapshot changes in total. 0 added, 4 modified, 0 deleted:

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@joshsny
Copy link
Contributor Author

joshsny commented Jan 22, 2025

@jurajmajerik thanks for these suggestions!

I really think the "Run experiment" option should be always visible in an insight, not just when the insight is saved. As a user, I personally don't save Insights that often. But I might want to run an experiment on them regardless.

I agree, have refactored the logic to pass metric instead of rely on insight.

Please add a tooltip to the "Run experiment" button explaining what it does (e.g. "open the experiment creation form where the metric is already prepopulated").

Done

When creating an experiment from an insight, it might be worth adding an info banner at the top of the experiment form. It's not super clear when/how the metric gets added to the experiment. There's no indication of the metric itself in the experiment form. So a banner explaining "please fill in these fields, click save and the experiment with your metric will be created" would be great.

Done, great suggestion. I don't love the UX for this page with having the metric on the next page, but it's out of scope of this PR to try and change that so the banner at least communicates something to the user.

Are you planning to add the usage event too?

Was waiting on this to merge, since that's done now I've added tracking for the cross sell.

Updated loom demo: https://www.loom.com/share/42aa7fcc2136495fb3302cdfdd58b19c?sid=dcad2565-d000-42ae-a23a-125ef560e674

Copy link
Contributor

@jurajmajerik jurajmajerik left a comment

Choose a reason for hiding this comment

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

Nice work! 🙌

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

24 snapshot changes in total. 0 added, 24 modified, 0 deleted:

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@joshsny joshsny changed the title feat: create experiment from an insight feat: create experiment from a funnel Jan 29, 2025
@joshsny joshsny merged commit 091b918 into master Jan 29, 2025
101 checks passed
@joshsny joshsny deleted the create-experiment-from-funnel branch January 29, 2025 11:48
adamleithp pushed a commit that referenced this pull request Jan 29, 2025
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
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.

4 participants