Integrate

Web snippet

A website loads the snippet issued after the traffic check and asks for one ad after the answer. The live URL is not on this page.

Last updated · 7 min read

On this page

A plain web chat app adds one container under the answer and loads the integration snippet Visor issues after the traffic check. The snippet asks for one ad. The page renders a card or a strip, or it renders nothing. This page shows the shape. It does not show a live URL.

Everything that looks like a script address or a function name below is illustrative. YOUR_SNIPPET_URL is a placeholder. The element id is yours. The real snippet is sent with the publisher agreement after the check passes. Publisher onboarding is that path. Placement is the rule the snippet has to follow.

The snippet you are issued

The publisher ID identifies the app. The snippet is how the page loads the slot. SDK access is the package. You cannot copy any of them from this site. They come after the traffic check. Sign-in is not connected yet, so there is no account area to open.

You can build the container and the empty state before the check. Do not request a live ad before approval. No ad is requested before approval. When the snippet arrives, point the script at that address and retire the placeholder.

The container and the script

Put an empty container where the ad is allowed to appear: in the thread, after the answer, full width of that column. Then load the script. Use async so the script does not block parsing. defer is the other choice: the script downloads without blocking and runs after the document is parsed. Use async or defer. A script tag with neither can delay the answer, which is the wrong trade.

Illustrative: container and scripthtml
<!-- Illustrative. YOUR_SNIPPET_URL is issued after the traffic check. -->
<div id="visor-slot"></div>
<script async src="YOUR_SNIPPET_URL"></script>

The container starts empty. Do not put a house message in it. Do not set a minimum height on it. Do not preload a skeleton. The id visor-slot in the sample is a name you choose so your own code can find the node. It is not a required id from a public API.

Load the script once per page. Do not inject a new copy of the same script on every token, or on every re-render. Asking for an ad is a separate step from loading the file, and it happens after the answer, once.

Ask after the answer

Render the model’s words first. When the stream has finished, and the answer is one you are willing to leave on screen, the snippet can ask. If the model refused, the turn errored, or the final text is empty, clear the container and do not ask. Placement is the reason. This page only shows where that hook sits in a web page.

Illustrative: ask after the answerjs
// Illustrative. This is your page, not a published Visor function.
// streamAnswer and renderAnswer are your code.
async function onQuestion(userText) {
  const answer = await streamAnswer(userText);
  renderAnswer(answer);

  const slot = document.querySelector("#visor-slot");
  const unusable = !answer || answer.empty || answer.refused || answer.error;
  if (unusable) {
    if (slot) slot.replaceChildren();
    return;
  }

  // Load the snippet once. How a finished answer asks for an ad
  // is described in the snippet you are issued. This page does not
  // name that function. YOUR_SNIPPET_URL is not a live address.
  ensureSnippet("YOUR_SNIPPET_URL");
}

function ensureSnippet(src) {
  const selector = 'script[src="' + src + '"]';
  if (document.querySelector(selector)) return;
  const script = document.createElement("script");
  script.async = true;
  script.src = src;
  document.head.appendChild(script);
}

onQuestion, streamAnswer, renderAnswer, and ensureSnippet are names in the sample so the order is readable. They are not Visor functions. How a finished answer triggers the request is part of the snippet you are issued. This page does not name that function, because the name is not published.

Data the page may pass

An app may send the current conversation or a short topic summary, anonymized in-app signals, device type, country, an under-18 flag, and a pseudonymous identifier. That is the public list. For a live request, country means the United States. A pseudonymous identifier is a stand-in the app chooses. It is not a name, an email, or a phone number.

Do not put a name, an email address, a phone number, precise location, payment data, or a government ID on the page for the snippet to read. Do not stash them in a data attribute, a query string, or a global. Do not send a third-party cookie. The privacy policy is the source. This page is a summary, not legal advice.

If a person types an email or a phone number into the chat, that text is inside the message. You can send a topic summary instead of the raw transcript. Prefer the summary when the transcript may contain a detail the person volunteered. Visor does not claim conversation text can never contain such a detail.

Mark an account under 18 in your own app, and do not request an ad for it. The privacy policy says that once a publisher marks an account as under 18, Visor does not request an ad. Do not send a birth date to make that mark.

When nothing comes back

If Visor returns nothing, render nothing. Empty the container. Do not leave the last ad in it. Do not swap in a house ad. An empty container with no height, no padding, and no minimum height is the right empty state. If your layout still shows a gap, remove the node until the next finished answer.

No-fill is a normal result. It is not a cue to call again in a loop on the same answer. One answer, one request, one slot. A later answer can ask again after it has finished.

Content security policy

A content security policy lists the origins a page may load. If your policy is locked down, you will need to allow the snippet’s origin in script-src. You may also need the origins that serve the ad’s image and its click, under the directives your policy already uses for images and connections. Those origins are issued with the snippet. They are not published on this page.

Do not loosen the policy to allow every origin in order to see an ad. Add the origins you were issued. Do not add a rule that turns off the policy for the whole app. The answer’s own scripts should stay as tight as they were.

Single-page apps

If the thread changes without a full page load, the snippet does not know your routes. Your code does. When the person starts a new answer, or navigates to another thread, drop the previous slot. Do not leave the last ad sitting under a new question.

  • Unmount the slot with the thread, or clear the container when the route changes.
  • Do not reuse the previous response under the next answer.
  • Ask again only after the new answer has finished.
  • Keep one container for the current answer, not a stack of containers from older turns.
  • If the component stays mounted across questions, reset it yourself. A client router will not do that for you.

A full page load is the simple case: the container starts empty, the script loads once, and the first finished answer may ask. A client-side router is the case that leaks an old ad if you forget to clear it. Treat a route change like the end of the turn.

Keep the answer fast

The answer is the product. The script must not sit on the path that paints it. Load with async or defer. Do not put a blocking script in the head ahead of the thread. Do not delay rendering the model’s words in order to warm the ad. If the script is slow, or if it never arrives, the person still has the answer.

Do not wait forever for a response before you let the thread move on. We do not publish a latency number. Choose a point, in your own code, after which you render nothing and leave the answer as it is. A spinner inside the slot that never resolves becomes a reserved gap. Take it down.

One script tag is enough. Do not load the snippet from several components at once. Do not attach it to every token of the stream. Extra loads compete with the answer and can paint more than one slot.

Before you copy this into production

  • Replace YOUR_SNIPPET_URL with the address you were issued. Do not ship the placeholder.
  • Confirm the slot is outside the answer node, and outside the assistant bubble.
  • Confirm a refusal, an error, and an empty answer leave no slot.
  • Confirm an empty response leaves no gap.
  • Confirm accounts marked under 18 do not ask.
  • Confirm the content security policy allows the issued origin, and no broader set.
  • Walk Testing and go-live on a phone-width window before US traffic hits the slot.

React and Next.js apps should read React and Next.js before they build a wrapper around this script. The placement rule does not change. The component boundary does.

Was something unclear? Contact support