Nuxt experiments installation
Install the PostHog JavaScript library using your package manager: This guide is for Nuxt v3.0 and above. For Nuxt v2.16 and below, see our Nuxt docs. Add your PostHog API key and host to your Create a new plugin by creating a new file To capture events from server routes, install Experiments 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. For client-side experiments, use the JavaScript snippet. For server-side experiments, use the Node.js snippet: Once 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.Install the package
RequiredAdd environment variables
Requirednuxt.config.js file:Create a plugin
Requiredposthog.client.js in your plugins directory:Server-side setup
Optionalposthog-node and instantiate it directly. You can also use it to evaluate feature flags on the server:Implement your experiment
RequiredRun your experiment
RequiredNext steps
RecommendedResource 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