<head> in app/root.tsx, with data-await-hydration="true". How you allow it in the Content Security Policy depends on your Hydrogen version.
Hydrogen 2026.4 and earlier
These versions set a Content Security Policy for you, so the script needs the policy’s nonce, and the policy needs pagent’s domains.Add the script
Add the tag at the top of the<head> in your Layout, with the nonce Hydrogen already gives you:
app/root.tsx
Allow pagent in the Content Security Policy
Inapp/entry.server.tsx, pass pagent’s domains to createContentSecurityPolicy:
app/entry.server.tsx
'unsafe-eval' in scriptSrc. Without it, those JavaScript changes don’t apply.
Hydrogen 2026.10 and later
Hydrogen 2026.10 removeduseNonce and createContentSecurityPolicy: your app owns its Content Security Policy now. Add the same tag without nonce:
app/root.tsx
Both versions
- Navigation between routes is tracked automatically.
Check it worked
- Deploy, then open your site in a private browser window.
- Back in pagent, click Check connection in the install step.
- Open a test’s preview link and check that the variant shows and stays after the page has finished loading.