@aqzhyi/google-analytics

0.3.5 • Public • Published

@aqzhyi/google-analytics

Google Analytics (GA4) library

Install

pnpm i @aqzhyi/google-analytics

Usage (Astro)

<GoogleAnalytics />

Insert the Google Tag Manager (GTM) script into the HTML using the Google Analytics ID you have configured (e.g., 'G-G90JYXXXXX').

  1. pages/_layout/BasicLayout.astro

    ---
    import { GoogleAnalytics } from '@aqzhyi/google-analytics'
    ---
    
    <!doctype html>
    <html>
      <head>
        <GoogleAnalytics id='G-G90JYXXXXX' />
      </head>
      <body>
        <slot />
      </body>
    </html>
  2. pages/index.astro

    ---
    import BasicLayout from "./_layout/BasicLayout.astro"
    ---
    
    <BasicLayout>
      Page 1
    </BasicLayout>
    

Preview

<GoogleAnalytics debug />

<GoogleAnalytics
  id=''
  debug={true}
/>

Preview

Package Sidebar

Install

npm i @aqzhyi/google-analytics

Weekly Downloads

6

Version

0.3.5

License

MIT

Unpacked Size

4.68 kB

Total Files

6

Last publish

Collaborators

  • pleasurazy