When the SDK is on a page but a survey doesn’t appear, the cause is usually one of three things: the SDK didn’t load, it can’t reach UserLoop, or the survey’s own rules keep it hidden for this visitor. The tools below tell them apart. For the messages UserLoop shows in the app, such as Needs setup, see The survey isn’t showing on your website.
Turn on debug messages
Add "debug":true to the options at the end of the snippet:
<script>
!function(w,d,o){if(w.userloop)return;var q=[],u=w.userloop={q:q};"init identify setAttributes track page show close reset setLanguage on off".split(" ").forEach(function(m){u[m]=function(){q.push([m,[].slice.call(arguments)])}});var s=d.createElement("script"),c=d.currentScript;s.async=1;s.src="https://cdn.userloop.io/sdk-3/userloop.js";if(c&&c.nonce)s.nonce=c.nonce;d.head.appendChild(s);u.init(o)}(window,document,{"siteKey":"SITE_KEY","debug":true});
</script>With the plain script tag, queue the init call yourself, as Install the SDK shows.
The browser console then shows warnings that start [UserLoop]: every error, and why a call such as show() did nothing. They never contain an answer, an email or an address with its query. Visitors’ consoles show them too, so remove "debug":true when you’ve finished.
Debugging doesn’t explain a survey that waits for its own trigger and never opens: the SDK checks those rules silently. To find which rule stops it, open it with show() (below), then work through the survey doesn’t show.
| Message | What it means |
|---|---|
[UserLoop] unknown SURVEY_ID |
show() named a survey that isn’t one of the site’s live website surveys. |
[UserLoop] origin SURVEY_ID |
show(): this page’s address isn’t one of the site’s addresses. |
[UserLoop] document SURVEY_ID |
show(): the survey has no question it can show this visitor. |
[UserLoop] frequency SURVEY_ID |
show(): this browser has already seen or answered the survey, and How often keeps it hidden. |
[UserLoop] busy SURVEY_ID |
Another survey is open. Only one opens at a time. |
[UserLoop] empty SURVEY_ID |
The survey was about to open, but has no question it can show this visitor. |
[UserLoop] no document |
show() was called, but the SDK wasn’t started with a site key. |
[UserLoop] site key |
init got a siteKey that isn’t a site key, so nothing was fetched. Copy the snippet again. |
[UserLoop] init ignored |
init was called a second time on the page. The first call stands. |
[UserLoop] user ID |
identify() was called without a user ID. |
[UserLoop] internal error |
Something failed inside the SDK. Nothing reached your page. Tell UserLoop’s support. |
[UserLoop] and an error code |
See An error event or error code. |
Open a survey straight away
In the console of a page of your site:
userloop.show("SURVEY_ID", { force: true });The survey opens at once. It skips the survey’s pages, Who rules, Share of visitors, its trigger and, with force, How often. It still needs the page to be on one of the site’s addresses, and no other survey open. Show a survey from code says where to find SURVEY_ID.
To try a survey without recording anything, pass preview: true instead:
userloop.show("SURVEY_ID", { preview: true });The survey replaces any survey already open. Its answers aren’t sent, it isn’t counted as shown, and this browser’s record for How often doesn’t change. It also ignores the survey’s question rules, so every question shows.
Test on your own computer
localhost,127.0.0.1and[::1]on any port always pass the address check. You don’t need to add them to the site’s addresses, and UserLoop won’t let you.- Pages there never count as installed. UserLoop’s Check installation needs a page loaded from the real site.
- Serve the page; don’t open the file. A page opened from disk (
file://) has no address the SDK can match, so it never shows a survey. Use a dev server, ornpx serveorpython3 -m http.server 8000in the folder. - The survey must still be published. The SDK on your computer reads the same live surveys as your site.
- Your browser remembers what it has seen. After a survey has shown once, How often may keep it hidden. Use
force: true, a private window, or clear the record and reload:
localStorage.removeItem("ul3.surveys");
sessionStorage.removeItem("ul3.session");
location.reload();userloop.version is undefined
The SDK hasn’t loaded. window.userloop may exist, but as the snippet’s stand-in, which has no version.
- The snippet isn’t on this page. View the page source and look for
cdn.userloop.io/sdk-3/userloop.js. If the site is built with a site builder or Google Tag Manager, check the change was published. - The Content-Security-Policy blocks it. The console shows a blocked request to
cdn.userloop.io. Addhttps://cdn.userloop.iotoscript-src, and allow the inline snippet with its nonce, its hash or'strict-dynamic'. Or use the plain script tag, which needs no inline allowance. - An ad or script blocker blocks it. Try a private window without extensions.
- The browser is too old. The SDK supports Chrome and Edge 90, Firefox 90 and Safari 14.1 and later. In a browser without
fetchor Shadow DOM, it does nothing and reports nothing.
An error event or error code
The SDK never throws into your page. When something fails, it emits an error event, and with debugging on it also logs [UserLoop], the code and the survey ID when there is one. To see them without debugging:
userloop.on("error", function (e) {
console.log("UserLoop error", e.code, e.surveyId);
});| Code | Cause | What to do |
|---|---|---|
site_fetch |
The SDK couldn’t fetch the site’s surveys from https://s.userloop.io. A network error or server error is retried once after 10 seconds first. A 404 means the site key is unknown. |
Check the site key against Settings → Website. Add https://s.userloop.io to connect-src. No survey shows on this page until it reloads. |
document_fetch |
show() was given a documentUrl that didn’t answer 200. |
Only UserLoop’s own survey pages use documentUrl. Remove it. |
invalid_document |
A survey’s data was incomplete, so the SDK skipped that survey. surveyId names it when it can. |
Publish the survey again. If it persists, tell UserLoop’s support. |
storage |
The browser refused storage: blocked site data, a full quota or a private window. | Nothing breaks: the SDK keeps working in memory for this page. How often then can’t remember across pages. |
submit |
An answer was dropped after the SDK stopped retrying: 10 attempts or 24 hours, or an answer the server refused. | Add https://data.userloop.io to connect-src. Check the visitor’s network. |
render |
A survey shown inside a page had no element to go in. | Check the element in Where on the page, or the target you passed, is on the page when the survey opens. |
renderer_load |
The file that draws surveys didn’t load within 10 seconds. The SDK tries again the next time a survey opens. | Add https://cdn.userloop.io to script-src. On a page that enforces Trusted Types, add a default policy that allows it. |
The SDK loaded, but the survey doesn’t show
userloop.version shows a version and there’s no error, yet the survey doesn’t appear. Check these, most likely first.
-
It isn’t live on this site. Only published website surveys reach the site, and a change reaches it when it is published, within two minutes. List what the site has:
fetch("https://s.userloop.io/api/site/SITE_KEY") .then((r) => r.json()) .then((site) => console.table(site.surveys.map((s) => ({ id: s.survey_id, title: s.survey }))));If the survey isn’t listed, publish it and check it is a website survey.
-
This browser has already seen or answered it. How often counts per browser. Try
show("SURVEY_ID", { force: true }), a private window, or clear the record as in Test on your own computer. -
This visitor answered another survey this visit. With One survey per visit on in Settings → Website, no other survey shows until the next visit. A new private window starts a new visit.
-
The page’s address isn’t on the list. Once the site has addresses, surveys show only on them:
example.comdoesn’t coverwww.example.com, and*.example.comdoesn’t coverexample.com. Runlocation.originin the console and compare it with Your site’s addresses. See Install the SDK. -
A targeting rule leaves this page or visitor out. In order, the SDK checks the pages (Show on, Don’t show on), the device, the browser’s language, the site the visitor came from, the campaign (
utm_values from the visit’s first page), new or returning, the visitor’s attributes, and Share of visitors. Type the page’s address under Test a page on the Targeting stage to check the pages. For attributes, check what your code set withJSON.parse(localStorage.getItem("ul3.attrs")). A visitor outside the share stays outside it: set Share of visitors to 100 while you test. -
The trigger hasn’t happened. After a wait counts from the page view. On scroll needs the scroll depth. On exit never opens on a phone or tablet. On a click needs a click on an element matching its selector, its text, or both when both are set. On an event needs
userloop.track()with exactly the Event name. From code never opens by itself. -
Another survey is open. Only one opens at a time. When two would open together, the higher Priority opens and the other is dropped.
-
The Content-Security-Policy blocks part of it. The console shows the blocked request. The page must allow:
Directive Sources script-srchttps://cdn.userloop.io, plus the snippet’s nonce, its hash or'strict-dynamic'connect-srchttps://s.userloop.io https://data.userloop.io https://survey-views.userloop.ioimg-srchttps: data:A blocked
script-srcgivesrenderer_loadwhen a survey is about to open. A blockedconnect-srcgivessite_fetchabout 10 seconds after the page loads. -
A survey inside a page has nowhere to go. No element matches Where on the page: an
errorevent with coderender.
UserLoop says the snippet isn’t on your site
The SDK can work on your computer while UserLoop’s own check still says Needs setup, because pages on localhost never count. Load a page of the real site, on one of its addresses, then select Check installation. The survey isn’t showing on your website explains each message.