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.
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.
-
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].
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].
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.