Advanced Customisation
Last updated: 30th May, 2022
💡 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:
- Hide the GoSquared Live Chat Widget
- Trigger Live Chat when clicking a custom button
- Pre-fill Assistant with a suggested reply
- Link to page a page with Assistant already open
- Override the default Assistant language/locale
- Secure Mode to help prevent malicious users
- Install Assistant on subdomains
- Troubleshooting with AdBlockers
Hide the GoSquared Live Chat Widget
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/gosquared.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.
Trigger Live Chat when clicking a custom button
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/gosquared.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 user'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 message history as they move between subdomains (e.g. 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.
Troubleshooting with AdBlockers
Enabling AdBlockers can cause disruption to customised Assistant functionality. This can sometimes result in the custom Chat icon appearing, but not opening once clicked, due to the AdBlocker.
A workaround is to only display your custom chat icon when GoSquared has actually loaded. If an Adblocker is on, GoSquared won’t load.
To set this up, you will need to hide the Assistant button by default:
_gs('set', 'chat', { button: false });
Then use the snippet below with an example function:
_gs('chat', function() { chat has now loaded, unhide custom icon })
🗣️ If you have any issues with advanced customisation of Assistant, just get in touch with us here!