Implementing Pageview Tracking

Chapter 2:

Step 3 - Add Google Analytics to Your Application

For users of the SSK Pro version, the Google Analytics integration is already included in the RootLayout component, which automatically injects the GoogleAnalytics component into your app. This means that tracking page views is handled globally without any additional setup required from your end.

Here’s how the RootLayout in SSK Pro includes Google Analytics:

import { GoogleAnalytics } from '@pro/analytics/GoogleAnalytics'

function RootLayout() {
  return (
    <>
      <GoogleAnalytics />
      {/* Other SSK-Pro features */}
    </>
  )
}

What this means:

  • No manual integration needed: Since the GoogleAnalytics component is already integrated in the RootLayout, it automatically tracks page views and user behavior site-wide.

  • Page view tracking is automatic: Every page you add to the Pro version of your app will already be tracked by Google Analytics. Just ensure that the GA_MEASUREMENT_ID environment variable is correctly set.

  • Cookie consent handling: The Google Analytics setup respects the user’s cookie consent, so data is only sent if users have agreed to it.

In summary: For Pro users, the Google Analytics tracking functionality is baked into the foundation of your application via the RootLayout. You simply need to ensure that your Google Analytics Measurement ID is correctly added to your .env file.

Last updated