yikes
yikes

Reputation: 1

Vercel Analytics Not Updating Visitors

I have added vercel analytics into my react app, and deployed it to vercel. However, the analytics are not being updated, and I am unsure if the cause is the way I am calling it.

Below is how my App.js is structured.

import React, { Suspense, lazy }  from 'react';
import { BrowserRouter as Router, Route, Routes } from 'react-router-dom';
import WelcomePage from './components/WelcomePage';
import ResultsPage from './components/ResultsPage';
import { Analytics } from '@vercel/analytics/react';

function App() {
  const QuizPage = lazy(() => import('./components/QuizPage'));

  return (
  <>
    <Router>
      <Suspense fallback={<div className="loading-screen" style={{backgroundColor: 'black'}}>Loading...</div>}>
        <Routes>
          <Route path="/" element={<WelcomePage />} />
          <Route path="/quiz" element={<QuizPage />} />
          <Route path='/results' element={<ResultsPage />} />
        </Routes>
        <Analytics />
      </Suspense>
    </Router>
  </>
  );
}

export default App;

I have tried putting <Analytics /> after the Router tag as well

Upvotes: 0

Views: 394

Answers (1)

Devon Ray
Devon Ray

Reputation: 840

I have Vercel analytics setup in CRA app and i've got the analytics imported into my entry point file, like this:

   <>
      <App />
      <Analytics />
   </>

This is also a duplicate of another question here, how to enable vercel web analytics in react app so perhaps something there could help.

Upvotes: 0

Related Questions