Install CoSurf

Everything you need to add CoSurf to a website and help your first visitor.

Add the script

Sign up, then copy your site key from Installation in the dashboard. Add these two tags to every page you want to help on, ideally in your shared layout or template, before </body>:

<script>
  window.CoSurfConfig = { key: 'YOUR_SITE_KEY' };
</script>
<script src="https://cdn.co-surf.com/js/cosurf-client.js" async></script>

That is all it needs. Open your site in another browser and the tab appears under Sessions in the dashboard within a few seconds. The script updates itself, so you never need to change the tag.

Name and ID

Pass the signed-in user's name and an ID so your team can tell visitors apart and find them quickly:

window.CoSurfConfig = {
  key: 'YOUR_SITE_KEY',
  name: 'Alex Morgan',
  identifier: 'user-4821',
  avatarUrl: 'https://example.com/avatars/4821.jpg'
};

With an identifier you can link from your own admin or helpdesk straight to that person's live tabs:

https://co-surf.com/agent?identifier=user-4821

If the user signs in after the page has loaded, call CoSurf.updateIdentity(name, identifier).

Help a visitor

  1. Open Sessions in the dashboard and choose the visitor.
  2. Their page opens in view-only mode. Pick a tool from the toolbar or press its number key: 1 view only, 2 click, 3 draw, 4 highlight, 5 spotlight.
  3. Use the session panel to refresh their page or request their console logs.

Privacy options

Password fields are never sent. These switches are under Installation > Visitor privacy and are on for new sites:

  • Visitor bar: while an agent is with them, visitors see "Someone can see this page to help you." with an End button. End stops CoSurf for the rest of that browser tab.
  • Hide card and contact fields: values typed into card, bank, email and phone fields show as stars to agents.

To hide the text inside any element, add data-cosurf-mask:

<div data-cosurf-mask>Account balance: £1,240.00</div>

To hide an element completely (agents see an empty box of the same size), use blockSelector:

window.CoSurfConfig = { key: 'YOUR_SITE_KEY', blockSelector: '.payment-form, #medical-notes' };

To ask visitors before CoSurf starts on their page, set requireConsent: true. They see a short prompt once per tab, and CoSurf only starts if they accept.

Under Installation > Allowed domains you can limit your site key to your own domains. With the list empty, the key works anywhere.

Start later

If you want CoSurf to start only for some users, or only once a user has signed in, add data-auto-init="false" and start it yourself:

<script src="https://cdn.co-surf.com/js/cosurf-client.js" data-auto-init="false"></script>
<script>
  CoSurf.init({ key: 'YOUR_SITE_KEY', name: user.name, identifier: user.id });
</script>

Pass autoStart: false to init and call CoSurf.start() when you are ready, for example from a "Get help" button.

Iframes

Iframes on the same domain as the page are captured with it; you do not add the script inside them. The browser does not let any script read an iframe from another domain, so those show as an empty box.

If you control the other domain, add the script inside that iframe with standalone: true. It then appears as its own session; give it the same identifier and agents can switch between it and the main page.

Content Security Policy

If your site sends a Content-Security-Policy header, allow the script and the live connection:

script-src https://cdn.co-surf.com;
connect-src wss://ws.co-surf.com;

All options

OptionDefaultWhat it does
keyYour site key. Required.
nameVisitor's name, shown to agents.
identifierYour ID for the visitor, used to group their tabs and to link to them.
avatarUrlPicture shown next to the visitor in the dashboard.
autoStarttrueConnect as soon as init runs.
requireConsentfalseAsk the visitor before starting.
consentTitle, consentMessage, consentAcceptText, consentDeclineTextWording for the consent prompt.
showVisitorBarsite settingShow the visitor bar. Overrides the site setting on this page.
visitorBarMessage, visitorBarEndTextWording for the visitor bar.
maskSensitiveFieldssite settingHide card, bank, email and phone fields. Overrides the site setting on this page.
maskTextSelector[data-cosurf-mask]Elements whose text is hidden.
blockSelectorElements hidden completely.
recordCanvastrueMirror canvas drawing.
canvasFps4Canvas frames a second on the main page.
iframeCanvasFps10Canvas frames a second inside same-domain iframes.
standalonefalseRun as its own session inside a cross-domain iframe.
sessionIdgeneratedUse your own session ID. A generated one lasts for the life of the tab.
debugfalseWrite extra detail to the browser console.

JavaScript API

CallWhat it does
CoSurf.init(options)Set the options above. Starts straight away unless autoStart is false. Safe to call before the script has loaded.
CoSurf.start()Connect, after the consent prompt if you have one.
CoSurf.stop()Disconnect. Agents see the visitor leave.
CoSurf.updateIdentity(name, identifier)Change the name and ID agents see.

Troubleshooting

  • The visitor does not appear. Open the browser console on your site. A line starting CoSurf v means the script loaded. "Invalid site key" means the key is wrong; "not allowed for this site key" means the domain is missing from Allowed domains.
  • Part of the page is blank for the agent. It is probably an iframe from another domain; see Iframes.
  • Still stuck? Email support@co-surf.com with your site's address.