# Deploying your tag (code snippet)

Pulse Insights is integrated into web-based environments with a JavaScript tag or code snippet that executes on page load.&#x20;

## Example Tag&#x20;

<pre class="language-javascript"><code class="lang-javascript"><strong>&#x3C;script>
</strong>(function() {
  var w = window, d = document;
  var s = d.createElement('script'); s.async = 1;
  s.src = '//js.pulseinsights.com/surveys.js';

  var f = d.getElementsByTagName('script')[0];
  f.parentNode.insertBefore(s, f);

  class PulseInsightsCommands extends Array{
    push(...commands) {
      commands.forEach((command) => window.PulseInsightsObject.processCommand(command));
    }
  }

  function waitPulseInsightsObject() {
    const timeoutPromise = new Promise((_, reject) => setTimeout(reject, 5000));
    const waitPromise = new Promise(function (resolve) {
      function wait() {
        if (typeof window.PulseInsightsObject == 'object') {
          resolve();
        } else {
          setTimeout(wait, 100);
        }
      }
      wait();
    });
    return Promise.race([timeoutPromise, waitPromise])
  }

  waitPulseInsightsObject().then(function () {
    w['pi']=function() {
      w['pi'].commands = w['pi'].commands || new PulseInsightsCommands;
      w['pi'].commands.push(arguments);
    };
    
    pi('host', 'survey.pulseinsights.com');
    pi('identify', 'PI-99999999); // This is an example value.
    pi('pushBeforeGet', true);
    pi('get', 'surveys');
  })
  .catch(function() {
    console.error('Failed to initialize window.PulseInsightsObject');
  });
})();
&#x3C;/script>
</code></pre>

## What the tag does&#x20;

* Identifies the browser, or creates a new Device UDID
* Fetches surveys to render, if any&#x20;
* Renders any survey with its appropriate [formatting](https://docs.pulseinsights.com/implementing-pulse-insights-dev/implementing-on-web-and-mobile-web/broken-reference)&#x20;
* Collects user responses, if the user answers&#x20;
* Executes [callbacks](https://docs.pulseinsights.com/implementing-pulse-insights-dev/implementing-on-web-and-mobile-web/callbacks), if any, to integrate the data with other tag-based vendors

## Finding your specific tag&#x20;

You can find your tag in your Console account under **Settings > Get Code Snippet** or by using your Tag Integration Guide that your Client Success Manager emailed to you.

<div align="left"><figure><img src="https://563760996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkJBdddbwa2Hgh4yTRC5g%2Fuploads%2FVNyY5p90d8vZRrDwmPV3%2FScreenshot%202023-05-02%20at%202.06.29%20PM.png?alt=media&#x26;token=065da05f-9c6c-4501-90dc-03049e42bdec" alt="" width="563"><figcaption></figcaption></figure></div>

{% hint style="info" %}
On rare occasions, Pulse Insights will customize your tag to better support your particular environment. If you received a Tag Integration Guide from your Client Success Manager with a modified tag, use that.&#x20;
{% endhint %}

## Tag Deployment FAQs&#x20;

### Which pages should have the Pulse Insights code snippet?&#x20;

In general, we recommend placing your snippet across all pages of your site(s). This enables easy survey launches in new site areas and accurate visit and session pageview count targeting.

If you're only using Pulse Insights on a specific selection of pages, it is OK to solely deploy the tag to those pages.&#x20;

### Where on the page should we place the code snippet?&#x20;

We recommend placing your Pulse Insights Code Snippet just above the closing body tag in the page or configuring to fire after the page content has loaded.&#x20;

### Can we use a tag manager to deploy Pulse Insights?

Yes. Pulse Insights is compatible with tag managers. We recommend using the Custom HTML option in case your specific tag differs from the tag manager's built-in tag template.

However, it should not be placed inside of a Doubleclick Floodlight Tag, as Pulse Insights needs access to the parent page to render a survey and Floodlight tags create an invisible iframe and load tags inside of it.

### Does the Pulse Insights tag work with \[X] CMS?

Yes, the CMS you use doesn't impact the tag's functionality.

### Do we use the same code snippet across secure/non-secure pages?‍&#x20;

Yes. The code snippet works across both http and https pages. There are no special configuration settings to enable HTTPS calls to render properly.

### Do we use the same tag across multiple domains and subdomains?&#x20;

Yes, you use the same code snippet across all domains, subdomains and environments on which you’d like to serve surveys and collect user feedback that are covered by your license. For questions regarding what is covered by your license, please reach out to your Client Success Manager.&#x20;

### Do we use the same tag across our development, staging, and production environments?

Yes, you use the same code across environments. Learn about our [QA features](https://docs.pulseinsights.com/implementing-pulse-insights-dev/implementing-on-web-and-mobile-web/qa-process-and-preview-mode).&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.pulseinsights.com/implementing-pulse-insights-dev/implementing-on-web-and-mobile-web/deploying-your-tag-code-snippet.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
