Docs/INSTALLATION GUIDES/Quick Start

CLI Installation

The TrackFox CLI is the fastest way to add analytics to your website. It automatically detects your framework, installs the tracking script in the correct location, and verifies the installation.

Quick Start

Install and run the CLI in one command:

npx trackfox add

That's it! The CLI will:

  1. Authenticate you with TrackFox
  2. Create or link your website
  3. Auto-detect your framework
  4. Install the tracking script
  5. Verify the installation

Installation

Option 1: Use with npx (Recommended)

No installation required - run directly:

npx trackfox add

Option 2: Install Globally

Install once, use anywhere:

npm install -g trackfox
trackfox add

Supported Frameworks

The TrackFox CLI supports automatic installation for 12 frameworks:

React Ecosystem

  • Next.js - Both App Router and Pages Router
  • React + Vite - Modern React applications
  • Create React App (CRA) - Traditional React setup
  • Remix - Full-stack React framework
  • Gatsby - Static site generator

Vue Ecosystem

  • Vue - Vite-based Vue projects
  • Nuxt - The Vue framework

Svelte Ecosystem

  • SvelteKit - The Svelte framework
  • Svelte - Vite-based Svelte projects

Other Frameworks

  • Astro - Content-focused framework
  • Angular - Full-featured framework
  • Static HTML - Plain HTML projects without a build system

How It Works

Step 1: Authentication

The CLI opens your browser for secure OAuth authentication:

$ npx trackfox add

🦊 TrackFox CLI - Add Website

Opening browser for authentication...
āœ“ Authenticated!

Step 2: Website Configuration

Enter your website details:

? What is your website domain? example.com
? What would you like to name this website? My Awesome Site
āœ“ Website created successfully!

Step 3: Automatic Installation

The CLI detects your framework and installs the script:

→ Setting up tracking script...
āœ“ Detected: Next.js 14.0.0 (App Router)
āœ“ Script installed successfully
āœ“ Changes validated

Step 4: Completion

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│          šŸŽ‰ Setup Complete!             │
│                                         │
│  āœ“ Website created                      │
│  āœ“ Tracking script installed            │
│  āœ“ Framework: Next.js 14.0.0 (App Router)│
│                                         │
│  Modified files:                        │
│    • app/layout.tsx                     │
│                                         │
│  Next steps:                            │
│    1. Review changes with git diff      │
│    2. Test your site locally            │
│    3. Deploy to production              │
│    4. Check dashboard for analytics     │
│                                         │
│  Dashboard:                             │
│    https://trackfox.app/dashboard/abc123│
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

⚠  Remember to deploy these changes to start tracking!

Your Tracking Script

The CLI installs a script that looks like this:

<script
  defer
  src="https://trackfox.app/script.js"
  data-website-id="your-website-id"
  data-domain="example.com"
></script>

Attributes:

  • defer - Ensures the script doesn't block page loading
  • data-website-id - Your unique website identifier
  • data-domain - Your website domain for tracking

Framework-Specific Details

Next.js

  • App Router: Installs in app/layout.tsx inside <head>
  • Pages Router: Installs in pages/_document.tsx inside <Head>

React + Vite / Vue

  • Installs in index.html inside <head>

Remix

  • Installs in app/root.tsx

SvelteKit

  • Installs in src/app.html inside <head>

Nuxt

  • Creates or updates app.vue or nuxt.config.ts

Astro

  • Installs in layout files (e.g., src/layouts/Layout.astro)

Angular

  • Installs in src/index.html inside <head>

Gatsby

  • Installs in gatsby-ssr.js using setHeadComponents

Static HTML

  • Detects HTML files and guides manual installation

Commands

trackfox add

Add a new website and install the tracking script:

npx trackfox add

What it does:

  1. Authenticates with TrackFox
  2. Prompts for website domain and name
  3. Creates website in your dashboard
  4. Auto-detects your framework
  5. Installs tracking script
  6. Creates backup of modified files
  7. Validates the installation

Backup & Safety

The CLI automatically creates backups before modifying files:

  • Backup location: {filename}.trackfox.backup
  • Example: app/layout.tsx.trackfox.backup

Verification

After installation, verify your setup:

  1. In your code: Check the modified file for the tracking script
  2. In your terminal: Review changes with git diff
  3. In your browser: Open DevTools Network tab and look for trackfox.app requests
  4. In your dashboard: Use the "Verify Installation" button in Site Settings

Troubleshooting

Framework Not Detected

Problem: CLI can't detect your framework

Solution:

  1. Ensure package.json exists in your project root
  2. Check that framework dependencies are installed
  3. For static HTML, make sure .html files exist
  4. Follow manual installation instructions

Script Already Installed

Problem: CLI says script is already installed

Solution:

  • The CLI detected an existing TrackFox script
  • No changes needed - you're already set up!
  • To reinstall, remove the existing script first

Permission Errors

Problem: EACCES or permission errors

Solution:

# Use npx instead of global install
npx trackfox add

# Or fix npm permissions
# https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally

Next Steps

After installing TrackFox with the CLI:

  1. Review changes: git diff to see what was modified
  2. Test locally: Run your development server and check the Network tab
  3. Deploy: Push changes to production
  4. Monitor: Check your dashboard for analytics
  5. Custom events: Learn about event tracking
  6. Revenue tracking: Set up revenue analytics

FAQ

Does it work with monorepos?

Yes, run the CLI from the specific package directory where your website code lives.

Can I use it in CI/CD?

The CLI is designed for local development. For CI/CD, we recommend committing the tracking script to your repository.

What data does the CLI send?

The CLI only sends:

  • Your authentication token (during OAuth)
  • Website name and domain (during website creation)
  • No source code or sensitive data is transmitted

Related Documentation

Need help? Contact us for assistance.

Suggest features? We'd love your feedback