Skip to main content
The Analytiq SDK is designed to be lightweight, zero-dependency, and environment-agnostic. This is the recommended approach for any modern JavaScript application using a bundler (Vite, Next.js, Webpack, etc.).
npm install analytiq
# or
yarn add analytiq
# or
pnpm add analytiq

Import Paths

Analytiq exports two entry points depending on your framework:
  1. The React Hook: Used strictly once in your root component for automatic setup (React & Next.js only).
    import { useAnalytiq } from 'analytiq/react';
    
  2. The Core SDK: Used for triggering events via track() in React, or for manual setup and tracking in Vanilla JS and Vue.
    import { init, identify, track, reset } from 'analytiq';
    

Using a CDN (Vanilla HTML/JS)

If you aren’t using a bundler and just want to include Analytiq in a basic HTML file, you can load it directly from the unpkg CDN. Place this script tags in your <head>:
<script src="https://unpkg.com/analytiq/dist/index.global.js"></script>
When loaded via <script>, the SDK exposes a global analytiq object attached to the window.
<script>
  // Initialize the SDK
  analytiq.init('pk_live_your_key_here', {
    autoTrackPageViews: true,
    debug: true
  });

  // Track an event
  document.getElementById('buy-btn').addEventListener('click', () => {
    analytiq.track('button_clicked', { source: 'landing_page' });
  });
</script>

Environment Compatibility

Analytiq handles SSR (Server-Side Rendering) gracefully. It works seamlessly with:
  • React (via analytiq/react hook)
  • Next.js App Router & Pages Router (via analytiq/react hook)
  • Vue & Nuxt (via core analytiq library)
  • Vanilla JS (via NPM or CDN)
React Native Support: The current stable version of Analytiq relies on browser localStorage and window objects. It is not currently compatible with React Native without polyfills. A dedicated React Native SDK is on our roadmap. Let us know if you need this!

What’s Next?

Pick your framework for a step-by-step integration guide:

React

Setup for React + Vite or Create React App

Next.js

Setup for Next.js App Router

Vue.js

Setup for Vue 3

Vanilla HTML

Setup for plain HTML websites

JavaScript (Plain JS)

Setup with plain JavaScript — no TypeScript

TypeScript

Setup with TypeScript support