Skip to content

Instantly share code, notes, and snippets.

@PaulieScanlon
Created June 20, 2024 14:38
Show Gist options
  • Save PaulieScanlon/57c155fa456cb51ee5724f2f26b5e07b to your computer and use it in GitHub Desktop.
Save PaulieScanlon/57c155fa456cb51ee5724f2f26b5e07b to your computer and use it in GitHub Desktop.
Google Analytics query
// src/index.js#L16
const [response] = await analyticsDataClient.runReport({
property: `properties/${process.env.GA4_PROPERTY_ID}`,
dateRanges: [
{
startDate: '7daysAgo',
endDate: 'today',
},
],
dimensions: [
{
name: 'fullPageUrl',
},
{
name: 'pageTitle',
},
],
metrics: [
{
name: 'activeUsers',
},
],
limit: 10,
metricAggregations: ['MAXIMUM'],
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment