Quick start
There are a few ways you can add Koala to your website or app.
- install the JavaScript snippet directly (keep reading!)
- install via Segment
- install via Google Tag Manager
Step 1: Copy the snippet
Navigate to Your Project > Settings in the Koala app and copy the JavaScript snippet and paste it into the <body>
tag of your site.
That snippet loads the Koala SDK onto the page asynchronously, so it won’t impact your page load speed.
It'll look something this:
<script>
!function(t){if(window.ko)return;window.ko=[],["identify","track", "removeListeners", "open", "on", "off", "qualify", "ready"].forEach(function(t){ko[t]=function(){var n=[].slice.call(arguments);return n.unshift(t),ko.push(n),ko}});var n=document.createElement("script");n.async=!0,n.setAttribute("src","https://cdn.getkoala.com/v1/<your project id>/sdk.js"),(document.body || document.head).appendChild(n)}();
</script>
Note: we recommend installing the Koala snippet on your marketing website, docsite, application and any other places that users are expressing intent in the product because Koala is going to surface this intent to the sales team. Koala can only surface intent that it can see, so it’s important to capture all of these surface areas.
Step 2: Identify users
The identify
method is how you tell Koala who the current visitor is. Koala uses email
as the primary identifier for identity merging. Until Koala knows a visitor's email, they will be considered anonymous.
After users have logged in, you can identify them by passing their email along with any other attributes you would like to see in Koala — for instance, their name.
Here's a basic example of what identify
might look like:
ko.identify('[email protected]')
You can also specify additional traits beyond just the email:
// specify multiple traits
ko.identify('[email protected]', {
name: 'Michael Bolton',
registered: true
})
// equivalent to:
ko.identify({
email: '[email protected]',
name: 'Michael Bolton',
registered: true
})
Note: If you're using Segment to install Koala, it will automatically send identify
calls to Koala by default (unless you've explicitly disabled it).
Troubleshooting
I'm seeing client-side errors about a "Content Security Policy" directive. What do I do?
If you are using a default Content Security Policy then adding the below to your default-src
rules will be sufficient.
default-src 'unsafe-inline' https://*.getkoala.com wss://*.getkoala.com
If you are using a more granular CSP then you'll need to add Koala to both the script-src
and connect-src
directives. If you have default-src 'none'
then you will need to add the following to your CSP:
script-src 'unsafe-inline' https://*.getkoala.com
connect-src https://*.getkoala.com wss://*.getkoala.com
Learn more about Content Security Policies: https://content-security-policy.com