Web Analytics doesnt work

Hi all, I’m running the tailwind-css-starterblog and am not able to implement the web analytics. I added the “yarn add @vercel/analytics” ; it is in my package.json.
I imported “import { Analytics } from ‘@vercel/analytics/react’” in my layout.tsx
adjusted the body to

<body className="bg-white pl-[calc(100vw-100%)] text-black antialiased dark:bg-gray-950 dark:text-white">
        <ThemeProviders>
          <Analytics />
          <SectionContainer>
            <SearchProvider searchConfig={siteMetadata.search as SearchConfig}>
              <Header />
              <main className="mb-auto">{children}</main>
            </SearchProvider>
            <Footer />
          </SectionContainer>
        </ThemeProviders>
      </body>
    </html>"

I was able to deploy and build the website without errors, but the analytics won’t work

What am I missing?

Any help is highly appreciated!

There are two sides to the analytics

  1. You must make sure your website is correctly loading and running the analytics script. From what you’ve shown it looks like you’ve done this correctly
  2. Vercel must be able to receive events from your website

I assume point 2 is the part that’s not working for you? What does your analytics tab look like in the dashboard for your project?

2 Likes

Hey there :waving_hand: Can you clarify what you’re seeing?

When you first deploy with the Analytics component it can take a few minutes for the first events to show up. You can also check manually in the browser’s network dev tools for requests being sent to /_vercel/insights/view - do you see these requests being made?

If so, we can tell that it’s at least sending events properly. If not, it might be a client issue. Let me know and we can try to narrow down the issue further.

1 Like

Oh wow it started to work itself after roughly 2hours, thanks for your help though! :slight_smile:

2 Likes

as I’m not a webdev and am new to vercel, could you please guide me to where to find thos requests?

To check if Vercel Analytics is working properly, open your browser’s developer tools (F12), go to the Network tab, filter for “insights” or “/_vercel/insights”, and look for requests to “/_vercel/insights/view” with successful status codes (200 or 204) :slight_smile:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.