npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rawdash/connector-google-analytics

v0.23.0

Published

Rawdash connector for Google Analytics 4 — syncs traffic, sources, pages, events, conversions, and geo data into the six-shape storage model

Downloads

2,074

Readme

@rawdash/connector-google-analytics

npm version license

Sync daily GA4 traffic, acquisition, top pages, events, conversions, and geography metrics from a Google Analytics 4 property.

Install

npm install @rawdash/connector-google-analytics

Authentication

Authenticate against the GA4 Data API with either a Google service account JSON key (recommended) or an OAuth 2.0 refresh-token tuple. The identity must have at least the Analytics Viewer role on the property.

  1. Find your GA4 Property ID under Google Analytics -> Admin -> Property settings (numeric, e.g. 123456789).
  2. Recommended: create a service account at Google Cloud -> IAM & Admin -> Service Accounts, generate a JSON key, and grant it the Analytics Viewer role on the property. Store the JSON as a secret and reference it as serviceAccountJson: secret("GA4_SERVICE_ACCOUNT_JSON").
  3. Alternative: provide an OAuth 2.0 refresh token with the analytics.readonly scope together with its clientId and clientSecret from the Google Cloud Console.

Configuration

| Field | Type | Required | Description | | -------------------- | ------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | | propertyId | string | Yes | Numeric ID of your GA4 property (e.g. 123456789). Find it in Google Analytics → Admin → Property settings. | | serviceAccountJson | secret | No | Contents of the JSON key file for a Google service account with the Analytics Viewer role. Create one at Google Cloud → IAM & Admin → Service Accounts. | | refreshToken | secret | No | Google OAuth 2.0 refresh token with analytics.readonly scope. Required if not using serviceAccountJson. | | clientId | string | No | OAuth 2.0 client ID from Google Cloud Console. Required when using refreshToken auth. | | clientSecret | secret | No | OAuth 2.0 client secret from Google Cloud Console. Required when using refreshToken auth. | | lookbackDays | number | No | How many calendar days to fetch on a full sync. Defaults to 90. |

Resources

  • ga4_traffic_by_day (metric) - Daily site traffic totals - sessions, total users, new users, page views, and engagement rate.
    • Endpoint: POST /v1beta/properties/{propertyId}:runReport
    • Unit: sessions
    • Granularity: day
    • Dimensions: date
  • ga4_traffic_by_source (metric) - Daily sessions and conversions broken down by acquisition source and medium.
    • Endpoint: POST /v1beta/properties/{propertyId}:runReport
    • Unit: sessions
    • Granularity: day
    • Dimensions: date, sessionSource, sessionMedium
  • ga4_top_pages (metric) - Daily page views and average session duration bucketed by page path.
    • Endpoint: POST /v1beta/properties/{propertyId}:runReport
    • Unit: page_views
    • Granularity: day
    • Dimensions: date, pagePath
  • ga4_events (metric) - Daily event counts and the users that triggered them, bucketed by event name.
    • Endpoint: POST /v1beta/properties/{propertyId}:runReport
    • Unit: events
    • Granularity: day
    • Dimensions: date, eventName
  • ga4_conversions (metric) - Daily conversion counts and total revenue bucketed by conversion event name.
    • Endpoint: POST /v1beta/properties/{propertyId}:runReport
    • Unit: conversions
    • Granularity: day
    • Dimensions: date, eventName
  • ga4_geo (metric) - Daily sessions and total users bucketed by visitor country.
    • Endpoint: POST /v1beta/properties/{propertyId}:runReport
    • Unit: sessions
    • Granularity: day
    • Dimensions: date, country

Example

import {
  defineConfig,
  defineDashboard,
  defineMetric,
  secret,
} from '@rawdash/core';

const googleAnalytics = {
  name: 'googleAnalytics',
  connectorId: 'google-analytics',
  config: {
    propertyId: '123456789',
    serviceAccountJson: secret('GA4_SERVICE_ACCOUNT_JSON'),
    lookbackDays: 90,
  },
};

export default defineConfig({
  connectors: [googleAnalytics],
  dashboards: {
    traffic: defineDashboard({
      widgets: {
        sessions: {
          kind: 'timeseries',
          title: 'Daily sessions',
          window: '30d',
          metric: defineMetric({
            connector: googleAnalytics,
            shape: 'metric',
            name: 'ga4_traffic_by_day',
            fn: 'sum',
          }),
        },
      },
    }),
  },
});

Rate limits

GA4 Data API quota is 200,000 tokens/day per property (default); 429 responses are retried automatically with exponential backoff.

Limitations

  • Incremental syncs use a 30-day window because GA4 can attribute conversions up to 3 days after the session.
  • Report pagination is 10,000 rows per page.

Links

License

Apache-2.0