Getting started

In your Bubble application editor, navigate to Settings in the left sidebar. Under SEO / metatags, find Script/meta tags in header.

Insert the following code snippet, taking care to replace INSERT_API_KEY_HERE with your API key:

<script>!function(){var e=window.Cohere=window.Cohere||[];if(e.invoked)console.error("Tried to load Cohere twice");else{e.invoked=!0,e.snippet="0.2",e.methods=["init","identify","stop","showCode"],e.methods.forEach(function(o){e[o]=function(){var t=Array.prototype.slice.call(arguments);t.unshift(o),e.push(t)}});var o=document.createElement("script");o.type="text/javascript",o.async=!0,o.src="https://static.cohere.so/main.js",o.crossOrigin="anonymous";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(o,t)}}();</script>

And you're good to go! Just open your Bubble application preview and you'll see the session show up on the Cohere dashboard.

Identifying users

Identifying users on Bubble requires the Toolbox plugin enabled for your application. If you do not have Toolbox installed, please visit this page to install it from the Bubble plugin marketplace.

In your Bubble application editor, navigate to Workflow in the left sidebar.

Add a new event, and select GeneralUser is logged in.

Add a new action, and select PluginsRun javascript. If you do not see this option, please install the Toolbox plugin.

In the Run Javascript modal that pops up, please insert the following snippet, replacing all user data with your Current User dynamic data.

window.Cohere.init("Current User's unique id", {displayName: "Current User's name", email: "Current User's email"})