Pagesmith.ai
P
  • Features
  • Pricing
  • Blog
  • Documentation
  • Contact
Start Building
Pagesmith.ai
P

From idea to stunning website in minutes. Just describe it, we'll build it.

All rights reserved.

Company
  • About Us
About
  • Blog
  • Contact
Product
  • Documentation
Learn
  • Lovable Alternative
  • Pagesmith vs WordPress
  • SEO for AI Sites
Legal
  • Terms of Service
  • Privacy Policy
  • Cookie Policy
English|Suomi
    • GitHub Integration
    • Hosting Options
    • Analytics Setup
  • Glossary
  • Changelog

Analytics Setup

Add analytics to your Pagesmith site. Google Analytics, Plausible, and other tracking tools.

Track visitors, conversions, and user behavior with analytics.

Adding Analytics

Via Code Editor

  1. Open Code tab in the editor
  2. Find your layout file (src/layouts/Layout.astro)
  3. Add the script before </head>

Via AI

Add [Analytics Provider] tracking to all pages.
Use tracking ID: [your-id]

Google Analytics 4

Add to your layout:

<!-- Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'G-XXXXXXX');
</script>

Replace G-XXXXXXX with your Measurement ID.

Plausible

Lightweight, privacy-focused alternative:

<script defer data-domain="yoursite.com"
  src="https://plausible.io/js/script.js"></script>

Benefits:

  • No cookies needed
  • GDPR compliant by default
  • Simpler dashboard
  • Better performance

Fathom

Another privacy-focused option:

<script src="https://cdn.usefathom.com/script.js"
  data-site="XXXXXXXX" defer></script>

Vercel Analytics

If hosting on Vercel:

npm install @vercel/analytics
---
import { Analytics } from '@vercel/analytics/react';
---
<Analytics />

What to Track

Page Views

All analytics tools track automatically.

Events

Track specific actions:

// Google Analytics
gtag('event', 'signup', {
  'event_category': 'conversion',
  'event_label': 'hero_cta'
});

// Plausible
plausible('Signup', { props: { location: 'hero' } });

Conversions

Track goal completions:

  • Form submissions
  • Button clicks
  • Purchases

Privacy Considerations

Cookie Consent

If using cookies (Google Analytics), add consent:

<!-- Show banner before loading analytics -->
<script>
  if (userConsented) {
    // Load analytics
  }
</script>

Cookieless Options

Plausible and Fathom don't use cookies — no consent banner needed.

Self-Hosted Analytics

For full control:

  • Plausible Cloud or self-hosted
  • Umami (open source)
  • Matomo

Debugging

Check Installation

  1. Open browser DevTools
  2. Go to Network tab
  3. Filter by analytics domain
  4. Verify requests are sent

Real-Time Reports

Most tools show real-time data:

  • Visit your site
  • Check real-time dashboard
  • Confirm tracking works

Related Docs

  • Publishing — Deploy your site
  • SEO Best Practices — Track search performance
  1. Adding Analytics
    1. Via Code Editor
    2. Via AI
    3. Google Analytics 4
    4. Plausible
    5. Fathom
    6. Vercel Analytics
    7. What to Track
    8. Privacy Considerations
    9. Debugging
    10. Related Docs