Note: This is not required for popover surveys.
If you're using PostHog's survey API to create a custom survey UI, there are 2 steps to integrating with PostHog:
Step 1: Fetch active surveys
To fetch the surveys currently enabled for a user, call posthog.getActiveMatchingSurveys(). 
Alternatively, if you wish to do survey targeting yourself, you can call posthog.getSurveys() to return a list of all surveys from PostHog.
Both methods return a callback with a surveys object:
Thus you can use show your user a survey using code like this:
Important:
posthog.getActiveMatchingSurveys()will always return an active survey if the user meets the targeting conditions, even if they have already seen, dismissed or responded to the survey.
Note: If you're using a URL or selector targeting options, you'll need to poll
posthog.getActiveMatchingSurveys()to get the most updated results.
Step 2: Capture survey events
To show survey results in PostHog, you need to capture user interactions with your surveys using the following 3 events:
Multiple question surveys
If you have a survey with multiple questions, you can capture the responses to each question using the following syntax:
If you want to make the most of PostHog's automatic survey analysis and results visualizations page, you'll need to capture survey responses in the above formats.