Documentation

Installation

Overview

UserView can be installed using one of the following methods:

  1. Installing via Script Tag - Directly add the code snippet to your web page.
  2. Installing via NPM - Ideal for projects using a Node.js environment.
  3. Installing via React - For React-based applications.

Choose the method that best fits your project's requirements.

You'll find your installation code within your UserView dashboard. Simply add the code anywhere on your webpage, or, if you prefer, add it to a JavaScript file by removing the tags from the code.

Recommendation: Make sure that the code loads as fast as possible by adding it as one of the first things that execute on the page.

Warning
While you can install UserView through Google Tag Manager or Segment, the preferred method is to paste the installation code directly on your website, as this will result in faster load times.

Installation remains the same whatever front end framework you use. UserView works fine with React, Angular, and most other modern JavaScript frameworks. All you need to do is add the code to the page.

Testing on a Local or Staging Environment

When you test on your own computer or in a staging environment that is not publicly accessible, you might notice some odd rendering issues.

This is because our proxy server is unable to reach your CSS and media files and therefore can't properly edit them to render on the Agent side.

We try to automatically detect if you are on a URL that looks like localhost (e.g. http://127.0.0.1/, http://localhost/, etc.), and send the content of CSS files directly from the Visitor's browser to the Agent's browser.

You can add more URLs for browser proxying in your dashboard settings.

Iframe Support

UserView will work with iframes without you needing to do anything when these are hosted on the same domain. This means that the part of the URL between :// and the first / is exactly the same (i.e. app.acme.com and dashboard.acme.com are considered different domains).

In this case, you only need to add the script to the outermost frame (i.e. the parent page).

You don't need to do anything to make UserView work cross-domain if iframes aren't involved.

Different Domains

To make UserView work when you have iframes on different domains/subdomains, you'll need to add the code to all the iframes. This is the code you get from your dashboard's installation page.

The iframes will connect automatically.

Using the SDK
The code will behave differently in the iframe, and you can't use SDK within it. That means that if you want to identify the user you'll need to do so in the outermost frame.

When You Have a Lot of Visitors

If your website has a lot of Visitors (i.e. over 5,000 connected at once), you might want to only connect Visitors who actually need help.

You can easily do this by passing autoconnect: false to the configuration, like this (or by turning this off in the dashboard):

// Rest of the installation code...
Upscope('init', {
 autoconnect: false
})

The visitor will be connected automatically if they have recently been in a Session, and will also automatically connect if they are shown the lookup code through any means.

You can also manually connect the Visitor by calling Upscope('connect');

CSP Rules

If you use Content Security Policy rules to protect your website, you'll need to add the following URLs to allow UserView to work correctly.

script-src 'self' https://code.upscope.io https://js.upscope.io;
connect-src wss://*.upscope.io https://*.upscope.io;
media-src https://js.upscope.io;
img-src https://app.upscope.io https://app-cdn.upscope.io;

Prototype.js

To make UserView compatible with some older versions of Prototype, include the following code before the installation code.

<script>
  if (window.Prototype) {
    delete Object.prototype.toJSON;
    delete Array.prototype.toJSON;
    delete Hash.prototype.toJSON;
    delete String.prototype.toJSON;
  }
</script>
` tags from the code."},{"type":"paragraph","id":"p-1","content":"**Recommendation:** Make sure that the code loads as fast as possible by adding it as one of the first things that execute on the page."},{"type":"callout","id":"warning-while-you-can-install-userview","title":"Warning","content":"While you can install UserView through Google Tag Manager or Segment, the preferred method is to paste the installation code directly on your website, as this will result in faster load times.","link":"https://cobrowsingapi.com/docs/sdk/web/installation#overview-installing-via-script-tag::alert::warning-while-you-can-install-userview-through-google","meta":{"calloutType":"disclaimer"}},{"type":"paragraph","id":"p-3","content":"Installation remains the same whatever front end framework you use. UserView works fine with React, Angular, and most other modern JavaScript frameworks. All you need to do is add the code to the page."}]},{"type":"tab","id":"overview-installing-via-npm","title":"Installing via NPM","link":"https://cobrowsingapi.com/docs/sdk/web/installation#overview-installing-via-npm","children":[{"type":"list","id":"list-0","children":[{"type":"list-item","id":"install-the-sdk","title":"","content":"Install the SDK","link":"https://cobrowsingapi.com/docs/sdk/web/installation#overview-installing-via-npm::li::install-the-sdk","children":[{"type":"code","id":"code-0","language":"shell","content":"npm install --save @upscopeio/sdk\n"}],"meta":{"raw":"Install the SDK"}},{"type":"list-item","id":"import-the-upscope-object","title":"","content":"Import the Upscope Object","link":"https://cobrowsingapi.com/docs/sdk/web/installation#overview-installing-via-npm::li::import-the-upscope-object","children":[{"type":"code","id":"code-0","language":"javascript","content":"import Upscope from '@upscopeio/sdk';\n"}],"meta":{"raw":"Import the Upscope Object"}},{"type":"list-item","id":"initialize","title":"","content":"Initialize","link":"https://cobrowsingapi.com/docs/sdk/web/installation#overview-installing-via-npm::li::initialize","children":[{"type":"code","id":"code-0","language":"javascript","content":"Upscope(\"init\", {\n apiKey: \"\"\n});\n"}],"meta":{"raw":"Initialize"}}],"meta":{"ordered":true}},{"type":"paragraph","id":"p-1","content":"**Note:** You can use the Upscope object wherever required, and call the same functions that are available with the regular installation. Initialization (`init`) needs to be called first and must include your public API key."},{"type":"section","id":"overview-installing-via-npm-public-api-key","title":"Public API Key","level":3,"link":"https://cobrowsingapi.com/docs/sdk/web/installation#overview-installing-via-npm-public-api-key","children":[{"type":"paragraph","id":"p-0","content":"You can find yours in the installation page of your UserView dashboard."}]}]},{"type":"tab","id":"overview-installing-via-react","title":"Installing via React","link":"https://cobrowsingapi.com/docs/sdk/web/installation#overview-installing-via-react","children":[{"type":"section","id":"overview-installing-via-react-installation","title":"Installation","level":3,"link":"https://cobrowsingapi.com/docs/sdk/web/installation#overview-installing-via-react-installation","children":[{"type":"paragraph","id":"p-0","content":"To incorporate UserView into your React project, first install the React-specific package using npm:"},{"type":"code","id":"code-1","language":"shell","content":"npm install --save @upscopeio/react\n"},{"type":"paragraph","id":"p-2","content":"Import the `UpscopeProvider` component and wrap your main application component with it."},{"type":"code","id":"code-3","language":"javascript","content":"import { UpscopeProvider } from '@upscopeio/react';\n\" enabled={true/false}>\n {/* rest of your app */}\n\n"},{"type":"callout","id":"entire-page-shared-userview-will-share-the-entire","title":"Entire page shared","content":"UserView will share the entire page, regardless of where the `UpscopeProvider` is added in your component hierarchy.","link":"https://cobrowsingapi.com/docs/sdk/web/installation#overview-installing-via-react-installation::alert::entire-page-shared-userview-will-share-the-entire","meta":{"calloutType":"disclaimer"}}]},{"type":"section","id":"overview-installing-via-react-configuration","title":"Configuration","level":3,"link":"https://cobrowsingapi.com/docs/sdk/web/installation#overview-installing-via-react-configuration","children":[{"type":"section","id":"overview-installing-via-react-configuration-public-api-key","title":"Public API Key","level":4,"link":"https://cobrowsingapi.com/docs/sdk/web/installation#overview-installing-via-react-configuration-public-api-key","children":[{"type":"paragraph","id":"p-0","content":"You can find yours in the installation page of your UserView dashboard."},{"type":"paragraph","id":"p-1","content":"The `UpscopeProvider` accepts props that you can use for additional configuration settings. These settings are similar to the ones you would specify using the `init` function in the standard SDK. For example, to specify a unique identifier for a user, you can do:"},{"type":"code","id":"code-2","language":"javascript","content":"\" enabled={true} uniqueId={user.email}>\n {/* Your application code here */}\n\n"}]}]},{"type":"section","id":"overview-installing-via-react-using-functionality-in-components","title":"Using Functionality in Components","level":3,"link":"https://cobrowsingapi.com/docs/sdk/web/installation#overview-installing-via-react-using-functionality-in-components","children":[{"type":"paragraph","id":"p-0","content":"To use UserView features in your individual components, you can use the `useUpscope` hook:"},{"type":"code","id":"code-1","language":"javascript","content":"import { useUpscope } from '@upscopeio/react';\nfunction YourComponent() {\n const {\n Upscope, // SDK object\n shortId, // Connected shortId or undefined\n getLookupCode, // Asynchronous function to get lookup code\n listen, // Event listener function\n reset, // Reset function\n isSharing // Boolean indicating active session\n } = useUpscope();\n // Your component logic here\n}\n"}]},{"type":"section","id":"overview-installing-via-react-additional-utilities-masking-and-disabling-remote-control","title":"Additional Utilities: Masking and Disabling Remote Control","level":3,"link":"https://cobrowsingapi.com/docs/sdk/web/installation#overview-installing-via-react-additional-utilities-masking-and-disabling-remote-control","children":[{"type":"paragraph","id":"p-0","content":"UserView offers utility components to mask sensitive data and disable remote control on specific UI elements."},{"type":"paragraph","id":"p-1","content":"To mask sensitive information:"},{"type":"code","id":"code-2","language":"javascript","content":"import { Masked, NoRemoteControl } from '@upscopeio/react';\nfunction YourComponent() {\n return (\n <>\n \n {/* Sensitive Info */}\n \n \n {/* Control Elements */}\n \n \n );\n}\n"},{"type":"paragraph","id":"p-3","content":"To disable remote control on a particular element:"},{"type":"code","id":"code-4","language":"javascript","content":"import { NoRemoteControl } from '@upscopeio/react';\nfunction YourComponent() {\n return (\n <>\n \n \n \n \n );\n}\n"},{"type":"paragraph","id":"p-5","content":"By following these steps and guidelines, you can fully integrate UserView into your React application and leverage its features effectively."}]}]}]}]},{"type":"section","id":"testing-on-a-local-or-staging-environment","title":"Testing on a Local or Staging Environment","level":2,"link":"https://cobrowsingapi.com/docs/sdk/web/installation#testing-on-a-local-or-staging-environment","children":[{"type":"paragraph","id":"p-0","content":"When you test on your own computer or in a staging environment that is not publicly accessible, you might notice some odd rendering issues."},{"type":"paragraph","id":"p-1","content":"This is because our proxy server is unable to reach your CSS and media files and therefore can't properly edit them to render on the Agent side."},{"type":"paragraph","id":"p-2","content":"We try to automatically detect if you are on a URL that looks like localhost (e.g. `http://127.0.0.1/*`, `http://localhost/*`, etc.), and send the content of CSS files directly from the Visitor's browser to the Agent's browser."},{"type":"paragraph","id":"p-3","content":"You can add more URLs for browser proxying in your dashboard settings."}]},{"type":"section","id":"iframe-support","title":"Iframe Support","level":2,"link":"https://cobrowsingapi.com/docs/sdk/web/installation#iframe-support","children":[{"type":"paragraph","id":"p-0","content":"UserView will work with iframes without you needing to do anything when these are hosted on the same domain. This means that the part of the URL between `://` and the first `/` is exactly the same (i.e. `app.acme.com` and `dashboard.acme.com` are considered different domains)."},{"type":"paragraph","id":"p-1","content":"In this case, you only need to add the script to the outermost frame (i.e. the parent page)."},{"type":"paragraph","id":"p-2","content":"You don't need to do anything to make UserView work cross-domain if iframes aren't involved."},{"type":"section","id":"iframe-support-different-domains","title":"Different Domains","level":3,"link":"https://cobrowsingapi.com/docs/sdk/web/installation#iframe-support-different-domains","children":[{"type":"paragraph","id":"p-0","content":"To make UserView work when you have iframes on different domains/subdomains, you'll need to add the code to all the iframes. This is the code you get from your dashboard's installation page."},{"type":"paragraph","id":"p-1","content":"The iframes will connect automatically."},{"type":"callout","id":"using-the-sdk-the-code-will-behave-different","title":"Using the SDK","content":"The code will behave differently in the iframe, and you can't use SDK within it.\nThat means that if you want to identify the user you'll need to do so in the outermost frame.","link":"https://cobrowsingapi.com/docs/sdk/web/installation#iframe-support-different-domains::alert::using-the-sdk-the-code-will-behave-differently","meta":{"calloutType":"disclaimer"}}]}]},{"type":"section","id":"when-you-have-a-lot-of-visitors","title":"When You Have a Lot of Visitors","level":2,"link":"https://cobrowsingapi.com/docs/sdk/web/installation#when-you-have-a-lot-of-visitors","children":[{"type":"paragraph","id":"p-0","content":"If your website has a lot of Visitors (i.e. over 5,000 connected at once), you might want to only connect Visitors who actually need help."},{"type":"paragraph","id":"p-1","content":"You can easily do this by passing `autoconnect: false` to the configuration, like this (or by turning this off in the dashboard):"},{"type":"code","id":"code-2","language":"javascript","content":"// Rest of the installation code...\nUpscope('init', {\n autoconnect: false\n})\n"},{"type":"paragraph","id":"p-3","content":"The visitor will be connected automatically if they have recently been in a Session, and will also automatically connect if they are shown the **[lookup code](/docs/sdk/the-lookup-code)** through any means."},{"type":"paragraph","id":"p-4","content":"You can also manually connect the Visitor by calling `Upscope('connect');`"}]},{"type":"section","id":"csp-rules","title":"CSP Rules","level":2,"link":"https://cobrowsingapi.com/docs/sdk/web/installation#csp-rules","children":[{"type":"paragraph","id":"p-0","content":"If you use Content Security Policy rules to protect your website, you'll need to add the following URLs to allow UserView to work correctly."},{"type":"code","id":"code-1","language":"diff","content":"script-src 'self' https://code.upscope.io https://js.upscope.io;\nconnect-src wss://*.upscope.io https://*.upscope.io;\nmedia-src https://js.upscope.io;\nimg-src https://app.upscope.io https://app-cdn.upscope.io;\n"}]},{"type":"section","id":"prototypejs","title":"Prototype.js","level":2,"link":"https://cobrowsingapi.com/docs/sdk/web/installation#prototypejs","children":[{"type":"paragraph","id":"p-0","content":"To make UserView compatible with some older versions of Prototype, include the following code before the installation code."},{"type":"code","id":"code-1","language":"html","content":"\n"}]}]},"https://cms-cdn.userview.com/www/data/docs-index-ml701z3k-7e16a1ff.json":[{"slug":"getting-started/implementation-overview","title":"Implementation Overview","order":1,"categoryOrder":0,"segmentOrders":[0,1]},{"slug":"getting-started/invite-team","title":"Invite Your Team","order":2,"categoryOrder":0,"segmentOrders":[0,2]},{"slug":"getting-started/co-browsing-faq","title":"Co-Browsing FAQ","order":3,"categoryOrder":0,"segmentOrders":[0,3]},{"slug":"getting-started","title":"Getting Started","order":999,"categoryOrder":0,"segmentOrders":[0,999]},{"slug":"sdk/web/installation","title":"Installation","order":1,"categoryOrder":1,"segmentOrders":[1,1,1]},{"slug":"sdk/web/configuration-options","title":"Configuration Options","order":2,"categoryOrder":1,"segmentOrders":[1,1,2]},{"slug":"sdk/web/sdk-functions","title":"SDK Functions","order":3,"categoryOrder":1,"segmentOrders":[1,1,3]},{"slug":"sdk/web/listening-for-events","title":"Listening for Events","order":4,"categoryOrder":1,"segmentOrders":[1,1,4]},{"slug":"sdk/web/translations","title":"Multi-Language Support","order":5,"categoryOrder":1,"segmentOrders":[1,1,5]},{"slug":"sdk/web","title":"Web SDK","order":999,"categoryOrder":1,"segmentOrders":[1,1,999]},{"slug":"sdk/ios/installation","title":"Installation","order":1,"categoryOrder":1,"segmentOrders":[1,2,1]},{"slug":"sdk/ios/configuration-options","title":"Configuration Options","order":2,"categoryOrder":1,"segmentOrders":[1,2,2]},{"slug":"sdk/ios/sdk-functions","title":"SDK Functions","order":3,"categoryOrder":1,"segmentOrders":[1,2,3]},{"slug":"sdk/ios/listening-for-events","title":"Listening for Events","order":4,"categoryOrder":1,"segmentOrders":[1,2,4]},{"slug":"sdk/ios","title":"iOS SDK","order":999,"categoryOrder":1,"segmentOrders":[1,2,999]},{"slug":"sdk/android/installation","title":"Installation","order":1,"categoryOrder":1,"segmentOrders":[1,3,1]},{"slug":"sdk/android/configuration-options","title":"Configuration Options","order":2,"categoryOrder":1,"segmentOrders":[1,3,2]},{"slug":"sdk/android/sdk-functions","title":"SDK Functions","order":3,"categoryOrder":1,"segmentOrders":[1,3,3]},{"slug":"sdk/android/listening-for-events","title":"Listening for Events","order":4,"categoryOrder":1,"segmentOrders":[1,3,4]},{"slug":"sdk/android","title":"Android SDK","order":999,"categoryOrder":1,"segmentOrders":[1,3,999]},{"slug":"sdk/element-masking","title":"Element Masking","order":999,"categoryOrder":1,"segmentOrders":[1,999]},{"slug":"sdk/identifying-the-visitor","title":"Identifying the Visitor","order":999,"categoryOrder":1,"segmentOrders":[1,999]},{"slug":"sdk","title":"SDK Documentation","order":999,"categoryOrder":1,"segmentOrders":[1,999]},{"slug":"sdk/the-lookup-code","title":"The Lookup Code","order":999,"categoryOrder":1,"segmentOrders":[1,999]},{"slug":"setup/connect-saml","title":"How to Connect Your SAML Provider","order":999,"categoryOrder":2,"segmentOrders":[2,999]},{"slug":"setup/crm-embed","title":"Embedding UserView Agent view on Another Page Using an Iframe","order":999,"categoryOrder":2,"segmentOrders":[2,999]},{"slug":"setup","title":"Setup","order":999,"categoryOrder":2,"segmentOrders":[2,999]},{"slug":"setup/integrate-live-chat","title":"Integrate your Live Chat Platform","order":999,"categoryOrder":2,"segmentOrders":[2,999]},{"slug":"setup/on-premise","title":"On-premise","order":999,"categoryOrder":2,"segmentOrders":[2,999]},{"slug":"using-userview/initiate-session/userview-app","title":"UserView App","order":1,"categoryOrder":3,"segmentOrders":[3,1,1]},{"slug":"using-userview/initiate-session/lookup-code","title":"Lookup Code","order":2,"categoryOrder":3,"segmentOrders":[3,1,2]},{"slug":"using-userview/initiate-session/agent-request-button","title":"Request Agent Button","order":3,"categoryOrder":3,"segmentOrders":[3,1,3]},{"slug":"using-userview/initiate-session","title":"Initiating a Session","order":999,"categoryOrder":3,"segmentOrders":[3,1,999]},{"slug":"using-userview/initiate-session/troubleshooting","title":"Troubleshooting","order":999,"categoryOrder":3,"segmentOrders":[3,1,999]},{"slug":"using-userview/userview-session-basics","title":"UserView Session Basics","order":1,"categoryOrder":3,"segmentOrders":[3,1]},{"slug":"using-userview/audio-calls","title":"Browser-to-Browser Audio Calls","order":999,"categoryOrder":3,"segmentOrders":[3,999]},{"slug":"using-userview","title":"Using UserView","order":999,"categoryOrder":3,"segmentOrders":[3,999]},{"slug":"using-userview/multi-agent-session","title":"Multi-Agent Session","order":999,"categoryOrder":3,"segmentOrders":[3,999]},{"slug":"using-userview/picture-in-picture","title":"Picture-in-Picture","order":999,"categoryOrder":3,"segmentOrders":[3,999]},{"slug":"using-userview/session-recording","title":"Session Recording","order":999,"categoryOrder":3,"segmentOrders":[3,999]},{"slug":"integrations/intercom/setup","title":"Setup","order":1,"categoryOrder":999,"segmentOrders":[999,999,1]},{"slug":"integrations/intercom/adding-userview-to-your-intercom","title":"Adding UserView to your Intercom Sidebar","order":2,"categoryOrder":999,"segmentOrders":[999,999,2]},{"slug":"integrations/intercom/user-guide","title":"User Guide","order":3,"categoryOrder":999,"segmentOrders":[999,999,3]},{"slug":"integrations/intercom/troubleshooting","title":"Troubleshooting","order":4,"categoryOrder":999,"segmentOrders":[999,999,4]},{"slug":"customization/custom-request-button","title":"Build Your Own Request Button","order":999,"categoryOrder":999,"segmentOrders":[999,999]},{"slug":"customization","title":"Customization","order":999,"categoryOrder":999,"segmentOrders":[999,999]},{"slug":"integrations/chatra","title":"Chatra","order":999,"categoryOrder":999,"segmentOrders":[999,999]},{"slug":"integrations/drift","title":"Drift","order":999,"categoryOrder":999,"segmentOrders":[999,999]},{"slug":"integrations/freshchat","title":"Freshchat","order":999,"categoryOrder":999,"segmentOrders":[999,999]},{"slug":"integrations/front","title":"Front","order":999,"categoryOrder":999,"segmentOrders":[999,999]},{"slug":"integrations/helpscout","title":"HelpScout","order":999,"categoryOrder":999,"segmentOrders":[999,999]},{"slug":"integrations","title":"Integrations","order":999,"categoryOrder":999,"segmentOrders":[999,999]},{"slug":"integrations/intercom","title":"Intercom","order":999,"categoryOrder":999,"segmentOrders":[999,999,999]},{"slug":"integrations/jivochat","title":"JivoChat","order":999,"categoryOrder":999,"segmentOrders":[999,999]},{"slug":"integrations/livechat","title":"LiveChat","order":999,"categoryOrder":999,"segmentOrders":[999,999]},{"slug":"integrations/olark","title":"Olark","order":999,"categoryOrder":999,"segmentOrders":[999,999]},{"slug":"integrations/reamaze","title":"Re:amaze","order":999,"categoryOrder":999,"segmentOrders":[999,999]},{"slug":"integrations/salesforce","title":"Salesforce","order":999,"categoryOrder":999,"segmentOrders":[999,999,999],"render":false},{"slug":"integrations/salesforce/salesforce-chat","title":"Salesforce Chat","order":999,"categoryOrder":999,"segmentOrders":[999,999,999]},{"slug":"integrations/salesforce/salesforce-crm","title":"Salesforce CRM","order":999,"categoryOrder":999,"segmentOrders":[999,999,999]},{"slug":"integrations/tawkto","title":"Tawk.to","order":999,"categoryOrder":999,"segmentOrders":[999,999]},{"slug":"integrations/tidio","title":"Tidio","order":999,"categoryOrder":999,"segmentOrders":[999,999]},{"slug":"integrations/trengo","title":"Trengo","order":999,"categoryOrder":999,"segmentOrders":[999,999]},{"slug":"integrations/zendesk","title":"Zendesk","order":999,"categoryOrder":999,"segmentOrders":[999,999]}]};