Vue experiments installation
- 1
Install the package
RequiredInstall the PostHog JavaScript library using your package manager:
Vue versionThis guide is for Vue 3 and above. For Vue 2.x, see our Vue docs.
- 2
Create a composable
RequiredCreate a new file
src/composables/usePostHog.js:src/composables/usePostHog.js - 3
Import in your router
RequiredIn
router/index.js, import theusePostHogcomposable and call it:router/index.js - 4
Implement your experiment
RequiredExperiments run on top of our feature flags. You can define which version of your code runs based on the return value of the feature flag:
- 5
Run your experiment
RequiredOnce you've implemented the feature flag in your code, you'll enable it for a target audience by creating a new experiment in the PostHog dashboard.
- 6
Next steps
RecommendedNow that you're running experiments, continue with the resources below to learn what else Experiments enables within the PostHog platform.
Resource Description Creating an experiment How to create an experiment in PostHog Adding experiment code How to implement experiments for all platforms Statistical significance Understanding when results are meaningful Experiment insights How to analyze your experiment data More tutorials Other real-world examples and use cases