Open jgeofil opened 2 days ago
// File: src/components/GoogleAnalytics.astro
---
const GA_TRACKING_ID = 'YOUR_GA_TRACKING_ID'; // Replace with your actual Google Analytics Tracking ID
---
<script async src={`https://www.googletagmanager.com/gtag/js?id=${GA_TRACKING_ID}`}></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', GA_TRACKING_ID);
</script>
<style>
/* Optional: Add styles if needed */
</style>
Make sure to replace 'YOUR_GA_TRACKING_ID' with your actual Google Analytics Tracking ID. This code snippet integrates Google Analytics into an Astro component, ensuring that analytics is properly enabled.
If there are specific analytics events or configurations you want to track beyond the basic page view.
Fix google tags ingration code to reenable anylitics with google analytics.