What is an API Key?
Your API key is a unique identifier that tells Analytiq which project your events belong to. It looks like this:init('pk_live_...'), Analytiq knows exactly which project dashboard to send your events to.
How to find your API Key
Step 1 — Log in to your dashboard at analytiq-two.vercel.app Step 2 — Click on the project you want to track Step 3 — Click Settings in the left sidebar Step 4 — Scroll down to the Public API Key section Step 5 — Click the Reveal button to show your key Step 6 — Click the Copy button to copy it to your clipboardUsing your API Key in code
Paste your API key as the first argument toinit():
Is it safe to put in frontend code?
Yes. API keys starting withpk_live_ are designed to be used in browser (frontend) code. This is a public key, not a secret key. Think of it like your project’s ID — it identifies your project, but it doesn’t give anyone access to your Analytiq account.
If you ever suspect your API key was compromised, you can rotate it from the Settings page. Rotating generates a new key and invalidates the old one immediately.
Using Environment Variables (Recommended)
Instead of hardcoding your key directly in code, store it in a.env file:
- React / Vite
- Next.js
- Vue
Create Use it in your code:
.env in your project root:Add
.env to your .gitignore file so it never gets uploaded to GitHub.Local vs Production API Keys
Each Analytiq project has its own API key. This means you should use separate projects for local development and production so that your test events don’t pollute your real analytics data.Recommended setup
Create two projects in the Analytiq dashboard:My App - Development— for local testingMy App - Production— for your live users
Setting the key in your local .env file
Setting the key in your hosting platform (production)
Do not put your production key in a.env file committed to GitHub. Instead, set it as an environment variable directly in your hosting platform’s dashboard:
| Platform | Where to add it |
|---|---|
| Vercel | Project Settings > Environment Variables |
| Render | Service Settings > Environment > Add Environment Variable |
| Railway | Service Settings > Variables |
| Netlify | Site Settings > Environment Variables |
| Heroku | Settings > Config Vars |
| AWS / GCP / Azure | Use their respective secrets manager or environment config |
VITE_ANALYTIQ_KEY (or NEXT_PUBLIC_ANALYTIQ_KEY for Next.js) to your production project’s API key in each platform.
Summary
| Environment | Where the key lives | Which project key to use |
|---|---|---|
| Local development | .env file (not committed) | Development project key |
| Production (deployed) | Hosting platform env variables | Production project key |
After updating an environment variable on your hosting platform, you must redeploy your app for the change to take effect.