Alytica Docs
Guides

Remix

Integrate Alytica with your Remix application.

1. Installation

npm install alytica-js

2. Create a Provider Component

Create app/components/AlyticaProvider.tsx:

import { useState, useEffect } from 'react';
import { Alytica } from 'alytica-js';
 
export function AlyticaProvider({ children }) {
  const [alytica, setAlytica] = useState(null);
 
  useEffect(() => {
    const alyticaInstance = new Alytica({
      clientId: 'your-client-id',
      clientSecret: 'your-client-secret',
      trackPageViews: true
    });
    setAlytica(alyticaInstance);
  }, []);
 
  return (
    <AlyticaContext.Provider value={alytica}>
      {children}
    </AlyticaContext.Provider>
  );
}

3. Wrap Your App

In app/root.tsx:

import { AlyticaProvider } from './components/AlyticaProvider';
 
export default function App() {
  return (
    <html>
      <body>
        <AlyticaProvider>
          {/* Your app content */}
        </AlyticaProvider>
      </body>
    </html>
  );
}

Best Practices

  • Replace 'your-client-id' and 'your-client-secret' with your actual Alytica credentials
  • Configure tracking options based on your specific requirements
  • Ensure compliance with privacy regulations when tracking user data

On this page