Skip to content
Powered byPagefind

Analytics

Integrate Google Analytics and Yandex Metrica with Unloyd.


Unloyd supports Google Analytics (GA4) and Yandex Metrica out of the box. Set the environment variable and deploy — no code changes needed.


Google Analytics (GA4)

  1. Get Your Measurement ID

    • Go to Google Analytics
    • Navigate to AdminData Streams → select or create a web stream
    • Copy the Measurement ID (format: G-XXXXXXXXXX)
  2. Add to Environment Variables

    PUBLIC_ANALYTICS_GOOGLE=G-XXXXXXXXXX
  3. Deploy

    The script loads automatically on build. No further setup needed.

Yandex Metrica

  1. Get Your Counter ID

    • Go to Yandex Metrica
    • Create a new counter and copy the Counter ID (numeric value)
  2. Add to Environment Variables

    PUBLIC_ANALYTICS_YANDEX=XXXXXXXXX
  3. Deploy

    The script loads automatically on build. No further setup needed.

How It Works

Both scripts are conditionally loaded in Head.astro — they only render if the corresponding environment variable is set. This keeps your site lightweight when analytics are not configured.

Privacy Considerations

Both services collect user data. Make sure your site has:

  • A Privacy Policy page
  • The built-in cookie consent system enabled
  • Clear notice to users about data collection