Skip to content

Analytics and Cookies

Depending on your needs, you may want to add analytics to your website, or manage cookies if you’re not using privacy focused analytics.

Analytics

If you wish to add analytics to your website, this is typically done by adding code to the <head> of the site. You can do this within the file ./src/layouts/BaseHead.astro. This file is included in all pages, and is where you can add / remove anything from the <head> of the site.

The below links have more info to walk you through setting up analytics with Astro.

Cookies!

If you’re using Google Analytics, you’ll need to manage cookies to be compliant with GDPR.

I have a blog post on implementing a basic cookie request modal that will help you set this up with GA4 here.