Which method should I use?
Option A — CDN (No npm, No Installation)
This is the simplest method. Just paste a<script> tag into your HTML and you are done.
Step 1 — Paste just before </body>
Open index.html and paste this block just above the closing </body> tag:
index.html example:
Track a button click
Track across multiple pages
If your site has multiple HTML pages (e.g.,about.html, contact.html), paste the script tag in each file. Because you set autoTrackPageViews: true, the SDK automatically records the page URL — no extra code needed per page.
Identify users after login
Option B — npm + Bundler (Vite, Webpack, Parcel)
Use this if you have a bundler but no framework like React or Vue.Step 1 — Install
Step 2 — Initialize in your entry file
Open your bundler’s entry file (usuallymain.js or index.js) and add at the top:
main.js
Step 3 — Track events anywhere in your project
any-file.js
Verify it’s working
- Open your HTML file in a browser
- Press F12 and go to Console tab
- You should see:
- Go to your Analytiq Dashboard then Events — events appear within 10 seconds.