jgeofil / mlreadme-astro-blog

https://mlreadme-astro-blog.vercel.app
0 stars 1 forks source link

Fix analytics #49

Open jgeofil opened 2 days ago

jgeofil commented 2 days ago

Fix google tags ingration code to reenable anylitics with google analytics.

linear[bot] commented 2 days ago

JGF-10 Remove GCM and fix anlytics

jgeofil commented 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.