Shopify

Getting started

In your Shopify store's admin dashboard, navigate to your store's Themes. Under your Current theme, select Actions Edit code.

Copy the following code snippet, making sure to replace INSERT_API_KEY_HERE with your API Key, which can be found on the Cohere dashboard under Settings.

<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"],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>
<script>window.Cohere.init("INSERT_API_KEY_HERE");</script>

Under Layout, in your theme file (usually theme.liquid), paste the above code into the <head> tag, like shown below:

And that's it — if you preview your store, you'll see your session appear on your Cohere dashboard! Once you push to production, everyone who visits your store will also be shown. You'll be able to see how they browse your store and, if they have questions or need help, you can call them and control their screen.

Identifying users

Identifying users on Shopify will require you to enable Customer Accounts on Shopify. To learn more, please check out the link here.

Copy the following code snippet.

{% if customer %}
<script>window.Cohere.identify({{ customer.id | json }}, {displayName: {{ customer.name | json }}, email: {{ customer.email | json }}});</script>
{% endif %}

Paste the code underneath the Cohere initialization code, in the <head> tag of your theme file (usually theme.liquid):

And that's it! Once your customer logs into your store, they will be identified with a name and email on the Cohere dashboard.