Advanced Assistant Customisation

These Assistant options allow you to customise the behaviour of the Assistant using extra code. These options will require the skills of a developer and access to your site's source code to implement.

This article covers:


Custom Assistant button or menu option

This is useful for if you want to move the Assistant button, replace it entirely, or perhaps just offer Live Chat as an option within a help menu.

Perhaps you just want to have a large 'Contact Us' button that instead of opening an email form, just pops the Assistant open – like on our contact page here.

1. Hide the default GoSquared Assistant button

To hide the default Assistant button, just add this extra line of code after the main GoSquared code snippet:

_gs('set', 'chat', { button: false });


So in context this would look like this:

<script>  
  !function(g,s,q,r,d){r=g[r]=g[r]||function(){(r.q=r.q||[]).push( 
  arguments)};d=s.createElement(q);q=s.getElementsByTagName(q)[0]; 
  d.src='//d1l6p2sc9645hc.cloudfront.net/tracker.js';
  q.parentNode.insertBefore(d,q)}(window,document,'script','_gs'); 
  _gs('GSN-XXXXXX-X'); 

  _gs('set', 'chat', { button: false });  
</script>

This will not turn Assistant off, it still loads in the background so that Prompts and other messages can be delivered – but the default button is hidden.
 

2. Trigger Assistant to open when clicking your own button/element

When using your own Assistant button, you will also have to account for where the button is positioned on your page and how that may change as a visitor scrolls down your webpage.

To open Assistant call this function:

_gs('chat', 'show');
 

To close Assistant call this function:

_gs('chat', 'hide');
 

So in the context of a button using the onclick event handler:

<button onclick="_gs('chat', 'show');">Talk to us now!</button>

Which gives you something like this 👇


Have a pre-filled reply when a visitor opens Assistant

When using a custom button/element to open Assistant, you can use an additional argument to pre fill the reply field with a suggested message. For example, on your contact sales page, you could pre-fill the reply with "Hi there, can I get a product demo?":

_gs('chat', 'show', 'Pre-filled reply goes here');


So in the context of a button this would look like this:

<button onclick="_gs('chat', 'show', 'Hi there, can I get a product demo?');">Chat with the Sales team</button>


Which gives you a button like this 👇


Link to a page with Assistant open and ready to chat

This can be useful if you want to include a link directly to a page with Assistant already popped open – for example including a chat link in your email footer.

You can do this by adding an extra line of code to your site combined with a custom URL that you can send to your customers. The extra code looks for the custom URL parameter and tells the Assistant to pop open when it finds it.


Example

The custom URL parameter we've used in this example is:

showchat=true

This means that when you want to link to a page on your site (with chat already open) you must add this parameter to the end of your URL. In the example below it's been added to the end of a 'contact-us' page. Use a ? to separate the main page URL from your custom parameter:

www.myexamplewebsite.com/contact-us?showchat=true

Then you need to add an extra line of code to your site that tells the Assistant to check for that same URL parameter:

if (/[&?]showchat=true/.test(location.href)) _gs('chat', 'show');


In context it would look like this, just add the extra line of code underneath your main GoSquared code snippet (remember to use your own project token rather than the example GSN-XXXXX-X one used here):

<script>
  !function(g,s,q,r,d){r=g[r]=g[r]||function(){(r.q=r.q||[]).push(
  arguments)};d=s.createElement(q);q=s.getElementsByTagName(q)[0];
  d.src='//d1l6p2sc9645hc.cloudfront.net/tracker.js';q.parentNode.
  insertBefore(d,q)}(window,document,'script','_gs');
  _gs('GSN-XXXXXX-X');

  if (/[&?]showchat=true/.test(location.href)) _gs('chat', 'show');
</script>


Override the Assistant language

You can set the default language of the Live Chat widget in Settings > Current Project > Assistant.

You can also turn on Auto detect language to automatically show Assistant in the same language as the users's browser.

However if you want to manually specify the language for different versions of your website, you can do this by overriding the default language using an extra line of code.

On the pages where you want to override the language, you need to add this extra code underneath the main GoSquared code snippet. In the example below the chat widget has been set to German:

_gs('set', 'chat', { locale: 'de' });

Note: the override will only work if it's included in the initial page load. You cannot override the language if Assistant has already loaded on the page.


Secure Mode

This prevents a malicious visitor from being able to impersonate another user by using somebody else's id. It ensures that tracked pageviews, events and chat messages can only be attributed to the genuine person actually sending them.

It requires you to use a server side hash function in conjunction with the front end javascript 'identify' method – please see our technical documentation.
 

Chatting across subdomains

To keep track of a user's Live Chat history as they move between subdomains (eg. app.mysite.com and mysite.com), you will need to use the cookieDomain configuration option with the Analytics code. This allows you to tell GoSquared to use the same tracking cookie across all of your subdomains. – read the full subdomain guide.

Did you find this article helpful?