This guide is for developers using plain JavaScript (no TypeScript). If you use TypeScript, see the TypeScript guide instead.
Step 1 — Install the SDK
Open your terminal inside your project folder and run:require() instead of import, no extra configuration is needed — the package ships with both formats built in.
Step 2 — All 5 functions in plain JavaScript
Step 3 — Using CommonJS require() syntax
If your project uses the older require() syntax (common in plain Node.js backends or older JavaScript projects):
Step 4 — In a React project (plain JS, no TypeScript)
Step 5 — In a Vue 3 project (plain JS)
Step 6 — Verify it is working
- Run your app:
npm run dev - Open the browser console (
F12, then Console tab) - You should see:
- Go to your Analytiq Dashboard, click your project, click Events in the sidebar
- Your event should appear within 5–10 seconds
Using environment variables (recommended)
Instead of pasting your API key directly in code, store it in a.env file: