Skip to main content
Once Sprig is installed in your prototype (see Installing Sprig in AI (“Vibe-Coded”) Prototypes), no-code events already cover most targeting needs. If you want finer control over when a study triggers, or more context about who’s responding, you can ask the AI for that too. Same method: paste a prompt into the chat.
You still don’t need to write or read any code. Give the AI the prompt below the same way you gave it the install snippet.
This works the same regardless of which AI prototyping tool you’re using.

Code Events

Code events let you trigger a study off something no-code events can’t see, for example a specific button click deep in a multi-step flow.
If you’re using Builder.io without deploying anywhere else, a code event isn’t optional there, it’s the only way to trigger a study in the Builder preview. See the Builder.io section of Installing Sprig in AI Prototypes for that specific prompt.
Ask the AI, depending on which install method you used:
  • If you installed the HTML snippet:
    Add Sprig('track', 'my_event_name') when [describe the moment, e.g. “the user clicks the Submit button” or “the page loads”].
  • If you installed via npm/pnpm:
    Add Sprig.track('my_event_name') when [describe the moment].
Replace my_event_name with whatever event name you’ve configured in Sprig, then create your study and set that as the trigger.

Attributes

Attributes attach extra context to a respondent, like their plan type or how long they’ve been a user, so you can filter your audience or dig into responses later. They’re nice to have, but never required to get a study running. Ask the AI, depending on which install method you used:
  • If you installed the HTML snippet:
    Add Sprig('setAttribute', 'attribute_name', 'value') when [describe the moment].
  • If you installed via npm/pnpm:
    Add Sprig.setAttribute('attribute_name', 'value') when [describe the moment].
Swap in your own attribute name and value (or ask for setAttributes/'setAttributes' with multiple key-value pairs at once, if you want to set several together). Once they start flowing in, you’ll see them on the Attributes page in your Sprig instance.
Not sure which install method you used? Check with whoever set it up, or look at your tool’s row in the “Ask the AI for…” column.