Back to Docs

Quick Start Guide

Get analytics working in your app in under 5 minutes.

1Get Your API Key

Go to Settings → API Keys and click "Generate New Key".

  • Give it a name (e.g., "Production", "Staging")
  • Select Write type for sending events
  • Copy the key - you'll only see it once!

2Add the SDK to Your App

Add this script to your HTML <head> or React layout:

<script>
!function(){var analytics=window.analytics=window.analytics||[];
if(!analytics.initialize)if(analytics.invoked)
window.console&&console.error("Analytics snippet included twice.");
else{analytics.invoked=!0;
analytics.methods=["init","page","track","identify","reset"];
analytics.factory=function(t){return function(){
var e=Array.prototype.slice.call(arguments);
e.unshift(t);analytics.push(e);return analytics}};
for(var t=0;t<analytics.methods.length;t++){
var e=analytics.methods[t];analytics[e]=analytics.factory(e)}
analytics.load=function(t,e){
var n=document.createElement("script");
n.type="text/javascript";n.async=!0;
n.src="https://analytics.chatnationbot.com/sdk.js";
var a=document.getElementsByTagName("script")[0];
a.parentNode.insertBefore(n,a);
analytics.init(t,e)};

// Initialize with your Write Key
analytics.load("YOUR_WRITE_KEY_HERE", {
  apiEndpoint: "https://analytics.chatnationbot.com/v1/capture"
});

// Track the initial page view
analytics.page();
}}();
</script>

3Track Events

Now you can track events anywhere in your app:

// Track a button click
analytics.track('Button Clicked', {
  button_id: 'signup',
  location: 'hero'
});

// Track a form submission
analytics.track('Form Submitted', {
  form_name: 'contact',
  email: 'user@example.com'
});

// Identify a logged-in user
analytics.identify('user_123', {
  email: 'user@example.com',
  name: 'John Doe',
  plan: 'premium'
});

4View in Dashboard

Events appear in your dashboard almost instantly. Go to:

Next Steps