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.

Example Tag

<script>
(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');
  });
})();
</script>

What the tag does

  • Identifies the browser, or creates a new Device UDID

  • Fetches surveys to render, if any

  • Renders any survey with its appropriate formatting

  • Collects user responses, if the user answers

  • Executes callbacks, if any, to integrate the data with other tag-based vendors

Finding your specific tag

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.

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.

Tag Deployment FAQs

Which pages should have the Pulse Insights code snippet?

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.

Where on the page should we place the code snippet?

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.

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?‍

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?

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.

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.

Last updated