If you don't want Upscope to load for all users because you have too many or for privacy concerns, you can use the following code to trigger Upscope only when needed.

1. Use this code

Instead of the traditional installation code, use the following:

<script>
  var upscopeApiKey = "API_KEY_HERE";
  function loadUpscope() {
    if(window.Upscope)
      return;

    (function(w, u, d){var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};var l = function(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://code.upscope.io/' + upscopeApiKey + '.js';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);};if(typeof u!=="function"){w.Upscope=i;l();}})(window, window.Upscope, document);

    Upscope('init');
    localStorage.setItem('loadUpscope', true);
  }

  if(localStorage.getItem('loadUpscope'))
    loadUpscope();
 
  function showSupportCode() {
    loadUpscope();
 
    Upscope('getLookupCode', function(code) {
      alert("Please tell our agent code " + code);
    });
  }
</script>

2. Edit the public api key

In the code above, change the second line so that API_KEY_HERE contains the key contained underneath the code here: https://upscope.io/install

3. Add a "Help" button

Use the following code to add a help button wherever you like on your website:

<a href="javascript:showSupportCode()">I need help!</a>

You can customize this however you like.

When the user clicks the button, he will be shown a 4 digit code to read your agent.

... or use javascript to load Upscope instead

Alternatively, you can just call loadUpscope();  or showSupportCode()  directly in your code.

4. Look for the code in the user list

Head over to https://app.upscope.io/ and enter the four digit code your user has given you and they will pop up on your screen.

Did this answer your question?