Sprig surveys are configured to trigger on the experimentation docs page to gather user feedback.
To enable Sprig surveys, you need to set the following environment variable:
NEXT_PUBLIC_SPRIG_ENVIRONMENT_ID=your-sprig-environment-id
For local development, create a .env.local file in the root directory:
# .env.local
NEXT_PUBLIC_SPRIG_ENVIRONMENT_ID=your-sprig-environment-idFor production, set the environment variable in your deployment platform:
- Vercel: Add the environment variable in your project settings
- GitHub Actions: Add as a repository secret and reference in your deployment workflow
- Other platforms: Follow your platform's documentation for setting environment variables
The survey is triggered when users visit the /docs/experiments page. The tracking event name is viewed_experimentation_docs.
In your Sprig dashboard:
- Create a survey
- Set up targeting based on the
viewed_experimentation_docsevent - Configure your survey questions and appearance
- The environment variable is prefixed with
NEXT_PUBLIC_because it needs to be available in the browser - The Sprig Environment ID is not sensitive like an API key, but should still be managed securely
- If the environment variable is not set, Sprig will not initialize and no surveys will be shown
To test the integration:
- Set up your local environment with the Sprig Environment ID
- Navigate to
/docs/experiments - Check your Sprig dashboard for the tracking event
- Verify that surveys are displayed according to your targeting rules