All skills
google avatar

/google-analytics-data-api-basics

@becc4b8
by googlegoogle/skills21k stars
1,698

Manages Google Analytics reporting data, enables the Analytics Data API via the Cloud CLI, and creates reports using the Google Analytics Data API (v1beta). Use when you need to interact with Google Analytics properties, run customized analytics reports, query metrics (like activeUsers, screenPageViews) and dimensions (like city, date), check metrics and dimensions compatibility, or verify API enablement. Don't use for Google Analytics Admin API operations (e.g., creating properties, managing users) or for front-end tracking installation.

Use this Skill: https://skilld.dev/gh/google/skills/google-analytics-data-api-basics

This session only. Nothing lands on disk.

referencesjava.md

≈668 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Google Analytics Data API Java Client Library Installation

This guide provides specific instructions for installing and setting up the Google Analytics Data API (v1beta) client library for Java.

Prerequisites

  • Java Development Kit (JDK): Java 8 or higher (Java 11+ recommended).
  • Build Tool: Maven or Gradle.
  • Authentication: Application Default Credentials (ADC) configured via gcloud auth application-default login.

Installation

Add the official Google Analytics Data client library dependency to your build file.

[!NOTE] For complete reference documentation, see the Google Cloud Java Analytics Data Repository.

[!TIP] Always replace LATEST_LIBRARY_VERSION with the latest stable version of the dependency available on Maven Central.

Option A: Maven (pom.xml)

Add the following dependency inside your <dependencies> tag in pom.xml:

<dependency>
  <groupId>com.google.cloud</groupId>
  <artifactId>google-cloud-analytics-data</artifactId>
  <version>LATEST_LIBRARY_VERSION</version>
</dependency>

Why: Using Maven ensures all required gRPC and protobuf message classes are added to your runtime classpath.

Option B: Gradle (build.gradle)

Add the following to your dependencies block:

implementation 'com.google.cloud:google-cloud-analytics-data:LATEST_LIBRARY_VERSION'

Quickstart / Usage

import com.google.analytics.data.v1beta.BetaAnalyticsDataClient;
import com.google.analytics.data.v1beta.RunReportRequest;
import com.google.analytics.data.v1beta.RunReportResponse;
import com.google.analytics.data.v1beta.DateRange;
import com.google.analytics.data.v1beta.Dimension;
import com.google.analytics.data.v1beta.Metric;

public class DataApiDemo {
  public static void main(String[] args) throws Exception {
    // Initialize BetaAnalyticsDataClient within try-with-resources.
    try (BetaAnalyticsDataClient client = BetaAnalyticsDataClient.create()) {
      RunReportRequest request = RunReportRequest.newBuilder()
          .setProperty("properties/1234567")
          .addDimensions(Dimension.newBuilder().setName("city"))
          .addMetrics(Metric.newBuilder().setName("activeUsers"))
          .addDateRanges(DateRange.newBuilder().setStartDate("2026-05-01").setEndDate("today"))
          .build();

      RunReportResponse response = client.runReport(request);
      response.getRowsList().forEach(row -> {
        System.out.printf("%s, %s%n", row.getDimensionValues(0).getValue(), row.getMetricValues(0).getValue());
      });
    }
  }
}

Source: SKILL.md on GitHub

No alerts10d3 checks · Risk SAFE
  • Gen Agent Trust Hub10d

    This skill provides a standard interface for interacting with the Google Analytics Data API v1beta across multiple programming languages. It includes established procedures for API enablement, authentication via the Google Cloud CLI, and client library installation. While the skill processes data from an external API, this is consistent with its intended reporting functionality and uses official vendor resources.

  • Socket10d

    No alerts

  • Snyk10d

    Risk: LOW · No issues

Signed by skilld at becc4b8. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated last week
metadata
{
  "version": "1.0.0",
  "category": "GoogleAnalytics"
}

README badge

README badge for google/skills/google-analytics-data-api-basics