Multi-Language Reference Implementations in the Google Skills Repository: A Complete Guide for Developers
The Google Skills repository provides production-ready reference implementations in eight programming languages—Ruby, Python, Java, Go, Node.js, .NET, PHP, and Perl—located in the references/ folders of each SKILL.
The multi-language reference implementations in the google/skills repository offer copy-paste-ready code snippets that demonstrate how to integrate with Google Cloud and Google Ads APIs. Each skill includes language-specific markdown files that handle authentication, client initialization, and API calls. These references enable developers to bootstrap applications quickly without rewriting boilerplate code for Google Analytics Data API, Analytics Admin API, or Google Ads API integrations.
Supported Programming Languages
The repository maintains comprehensive reference files for eight distinct programming languages. Each language implementation follows consistent patterns for client initialization and API execution.
- Ruby – Full support across Analytics and Ads APIs with idiomatic gem usage
- Python – BetaAnalyticsDataClient implementations with standard Google Cloud libraries
- Java – Auto-generated client examples using the Analytics Data SDK
- Go – Cloud.google.com/go module examples with context-based handling
- Node.js – Promise-based JavaScript examples using the @google-analytics/data package
- .NET (C#) – Google.Analytics.Data.V1Beta client implementations
- PHP – PSR-4 compliant examples using the Google Cloud PHP SDK
- Perl – Google Ads API support via the Google::Ads::GoogleAds module
Repository Structure and File Locations
Each skill in the repository organizes its multi-language reference implementations under a dedicated references/ subdirectory. The parent SKILL.md file catalogs available languages for that specific skill, allowing developers to locate their preferred implementation quickly.
Google Analytics Data API References
The Analytics Data API basics skill contains the broadest language coverage. Reference files reside in skills/analytics/google-analytics-data-api-basics/references/ and include:
-
ruby.md– Ruby implementation usingGoogle::Analytics::Data::V1beta::AnalyticsDataService::Client -
python.md– Python client usingBetaAnalyticsDataClient -
java.md– Java examples withAnalyticsDataClient.create() -
go.md– Go implementations usinganalyticsdata.NewAnalyticsDataClient -
nodejs.md– Node.js examples withBetaAnalyticsDataClient -
dotnet.md– C# implementations usingAnalyticsDataClient.Create() -
php.md– PHP examples usingAnalyticsDataClient
Google Analytics Admin API References
The Admin API skill provides cross-language examples in skills/analytics/google-analytics-admin-api-basics/references/ covering Ruby, Python, Java, Go, PHP, and Node.js implementations for account and property management tasks.
Google Ads API Quickstart References
Located in skills/ads/google-ads-api-quickstart/references/, these files demonstrate campaign creation and management across Ruby, Python, Java, PHP, Perl, and .NET. The Perl implementation specifically targets the Google Ads API with specialized authentication flows.
Implementation Examples by Language
Each reference file contains runnable snippets that initialize clients and execute run_report calls against the Google Analytics Data API. Below are extracted examples showing the consistent pattern across languages.
Ruby Implementation
# Load the Analytics Data API client
require "google/analytics/data/v1beta"
client = Google::Analytics::Data::V1beta::AnalyticsDataService::Client.new
response = client.run_report(
property: "properties/123456789",
dimensions: [{ name: "country" }]
)
puts response
Python Implementation
from google.analytics.data_v1beta import BetaAnalyticsDataClient
from google.analytics.data_v1beta.types import RunReportRequest, Dimension
client = BetaAnalyticsDataClient()
request = RunReportRequest(
property="properties/123456789",
dimensions=[Dimension(name="country")]
)
response = client.run_report(request)
print(response)
Java Implementation
import com.google.analytics.data.v1beta.AnalyticsDataClient;
import com.google.analytics.data.v1beta.RunReportRequest;
import com.google.analytics.data.v1beta.Dimension;
AnalyticsDataClient client = AnalyticsDataClient.create();
RunReportRequest request = RunReportRequest.newBuilder()
.setProperty("properties/123456789")
.addDimensions(Dimension.newBuilder().setName("country").build())
.build();
RunReportResponse response = client.runReport(request);
System.out.println(response);
Go Implementation
import (
"context"
"fmt"
"cloud.google.com/go/analyticsdata/apiv1beta"
analyticspb "cloud.google.com/go/analyticsdata/apiv1beta/analyticspb"
)
ctx := context.Background()
client, _ := analyticsdata.NewAnalyticsDataClient(ctx)
req := &analyticspb.RunReportRequest{
Property: "properties/123456789",
Dimensions: []*analyticspb.Dimension{{Name: "country"}}
}
resp, _ := client.RunReport(ctx, req)
fmt.Println(resp)
Node.js Implementation
const {BetaAnalyticsDataClient} = require('@google-analytics/data');
const client = new BetaAnalyticsDataClient();
async function getReport() {
const [response] = await client.runReport({
property: 'properties/123456789',
dimensions: [{name: 'country'}]
});
console.log(response);
}
.NET (C#) Implementation
using Google.Analytics.Data.V1Beta;
var client = AnalyticsDataClient.Create();
var request = new RunReportRequest {
Property = "properties/123456789",
Dimensions = { new Dimension { Name = "country" } }
};
var response = client.RunReport(request);
Console.WriteLine(response);
PHP Implementation
use Google\Analytics\Data\V1beta\AnalyticsDataClient;
use Google\Analytics\Data\V1beta\RunReportRequest;
use Google\Analytics\Data\V1beta\Dimension;
$client = new AnalyticsDataClient();
$request = (new RunReportRequest())
->setProperty('properties/123456789')
->setDimensions([(new Dimension())->setName('country')]);
$response = $client->runReport($request);
print_r($response);
Perl Implementation
use Google::Analytics::Data::V1beta::AnalyticsDataService::Client;
use Google::Analytics::Data::V1beta::RunReportRequest;
use Google::Analytics::Data::V1beta::Dimension;
my $client = Google::Analytics::Data::V1beta::AnalyticsDataService::Client->new();
my $request = Google::Analytics::Data::V1beta::RunReportRequest->new(
property => 'properties/123456789',
dimensions => [Google::Analytics::Data::V1beta::Dimension->new(name => 'country')]
);
my $response = $client->RunReport($request);
print $response;
How to Use the Reference Files
To implement these multi-language reference implementations in your project, navigate to the specific skill's references/ directory and select the .md file matching your programming language. Each file contains three essential components: dependency installation instructions, client initialization code, and API method calls with placeholder values for property IDs and dimensions. Replace the placeholder "properties/123456789" string with your actual Google Analytics 4 property ID and configure Application Default Credentials before executing the snippets.
Summary
- The Google Skills repository maintains eight language-specific reference implementations: Ruby, Python, Java, Go, Node.js, .NET, PHP, and Perl.
- Reference files live in
references/subdirectories within each skill folder, such asskills/analytics/google-analytics-data-api-basics/references/python.md. - Each implementation demonstrates proper client initialization using language-specific SDKs like
BetaAnalyticsDataClientfor Python orAnalyticsDataClientfor Java and C#. - The reference code handles the complete lifecycle from authentication through the
run_reportmethod execution. - Developers can copy snippets directly from files like
ruby.mdorgo.mdand adapt only the property ID and dimension parameters for immediate API access.
Frequently Asked Questions
How do I find the reference implementation for my programming language?
Navigate to the references/ folder within any skill directory in the google/skills repository. Each language has a dedicated markdown file (e.g., java.md, nodejs.md, php.md) containing complete implementation examples. The parent SKILL.md file lists all available languages for that specific API.
Are these reference implementations production-ready?
Yes, the code snippets in the repository use official Google Cloud client libraries and follow current best practices for authentication and error handling. However, you must replace placeholder values like "properties/123456789" with your actual Google Analytics 4 property identifiers and configure proper credentials before deploying to production environments.
Which languages support the Google Ads API specifically?
According to the source code in skills/ads/google-ads-api-quickstart/references/, the Google Ads API quickstart provides reference implementations for Ruby, Python, Java, PHP, Perl, and .NET. Go and Node.js references for Google Ads are not currently included in the Analytics Data API skill structure.
Do I need to install specific client libraries before using these examples?
Yes, each multi-language reference implementation requires the installation of language-specific Google Cloud SDK packages. For example, Python requires google-analytics-data, Ruby needs the google-analytics-data gem, and Node.js requires @google-analytics/data. Each reference file includes the specific package names and installation commands for that ecosystem.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →