← All IntegrationsIntegration

Analytics for GitHub Actions

Shift analytics left into your CI/CD pipeline. The BetterMeter CLI runs inside GitHub Actions to post traffic impact summaries on pull requests, generate weekly reports, and track CI pipeline usage — all automated, no dashboard required.

Post traffic impact on pull requests

After each production deploy, this workflow pulls today’s traffic and comments on the merged PR with the change against the previous day. bettermeter stats --json already returns visitorsChange and pageviewsChange, so the workflow only has to format them. Your team sees the real-world impact of every change without leaving GitHub.

.github/workflows/traffic-report.yml
name: Traffic Impact Report
on:
  deployment_status:

jobs:
  report:
    if: github.event.deployment_status.state == 'success'
    runs-on: ubuntu-latest
    env:
      # Passed to the CLI with --site. There is no site environment variable.
      SITE_DOMAIN: your-domain.com
    steps:
      - uses: actions/checkout@v4

      - name: Install BetterMeter CLI
        run: npm install -g bettermeter

      - name: Generate traffic report
        env:
          # Both are required together, or every command exits with
          # "BETTERMETER_API_KEY and BETTERMETER_URL must be set together."
          BETTERMETER_API_KEY: ${{ secrets.BETTERMETER_API_KEY }}
          BETTERMETER_URL: https://bettermeter.com
        run: |
          bettermeter stats --site "$SITE_DOMAIN" --range today --json > stats.json

      - name: Comment on PR
        uses: actions/github-script@v7
        with:
          script: |
            const fs = require('fs');
            const s = JSON.parse(fs.readFileSync('stats.json', 'utf8'));
            const pct = (n) => (n >= 0 ? '+' : '') + n + '%';
            const delta = s.hasPreviousPeriodData
              ? 'Visitors ' + pct(s.visitorsChange) + ', pageviews ' + pct(s.pageviewsChange) + ' vs. the previous day.'
              : 'No previous-day data to compare against yet.';
            const body = '## 📊 Traffic Impact Report\n\n'
              + '**' + s.visitors + '** visitors, **' + s.pageviews + '** pageviews, '
              + '**' + s.sessions + '** sessions today.\n\n' + delta;
            const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({
              owner: context.repo.owner,
              repo: context.repo.repo,
              commit_sha: context.sha,
            });
            if (prs.length > 0) {
              await github.rest.issues.createComment({
                owner: context.repo.owner,
                repo: context.repo.repo,
                issue_number: prs[0].number,
                body,
              });
            }

CI pipeline analytics

Track how often your CLI tools are invoked inside CI environments. The @bettermeter/node SDK detects GitHub Actions automatically via the CI and GITHUB_ACTIONS environment variables and tags events accordingly.

  • 01Automated reporting — Schedule weekly traffic summaries via cron-triggered workflows.
  • 02Deploy correlation — Compare traffic before and after each deploy automatically.
  • 03CLI usage in CI — Track which CLI commands your pipelines invoke and how often.
  • 04MCP tool tracking — If your CI runs MCP servers, BetterMeter captures tool invocations too.
PR Comments
Traffic impact per deploy
Cron Reports
Scheduled summaries
CI Detection
Auto-tags CI events