Google Tag Manager
Cohere can be added to your site Google Tag Manager, but we generally recommend directly embedding the script tag as GTM is commonly disabled by ad blockers.
Visit the Cohere dashboard to retrieve your API key. If you haven't previously connected a session, you should see it in the main screen. Otherwise, you can find it in the settings page.
Create the main Cohere tag by adding a custom tag in your GTM container:
Paste the following in the HTML section (replacing INSERT_API_KEY_HERE with your team's API key):
1
<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","getSessionUrl","makeCall","addCallStatusListener","removeCallStatusListener","widget","addSessionUrlListener","removeSessionUrlListener",],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>
2
<script>window.Cohere.init("INSERT_API_KEY_HERE");</script>
Copied!
Lastly, add the "All pages" trigger to the tag:
The Cohere script should be installed after:
  1. 1.
    Saving the tag
  2. 2.
    Publishing a new version of the container
You may now want to identify logged-in users based off of variables.
Last modified 12d ago
Copy link