Skip to main content
Glama
kpi_report.js1.15 kB
#!/usr/bin/env node import 'dotenv/config'; import { AnalyticsClient } from '../dist/analytics/client.js'; async function run() { const ga4PropertyId = process.env.GA4_PROPERTY_ID; if (!ga4PropertyId) { console.error('Missing GA4_PROPERTY_ID'); process.exit(1); } console.log('Checking KPIs for Property: ' + ga4PropertyId); try { const analytics = await AnalyticsClient.create(); const report = await analytics.runReport( ga4PropertyId, [{ startDate: '30daysAgo', endDate: 'today' }], [{ name: 'eventName' }], [{ name: 'eventCount' }], 50 ); console.log('\nEvent Breakdown (Last 30 Days):'); console.log('Event Name | Count'); console.log('--------------------|------'); if (report.rows) { report.rows.forEach(row => { console.log(row.dimensionValues[0].value.padEnd(20) + ' | ' + row.metricValues[0].value); }); } else { console.log('No rows returned.'); } } catch (e) { console.error(e); } } run();

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ehukaimedia/google-webmaster-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server