All skills
google avatar

/google-ads-api-quickstart

@329fa26
by googlegoogle/skills21k stars
1,698

Guides developers through Google Ads API quickstart: credential setup, choosing from 6 client libraries/REST, configuring environments, and running a "retrieve campaigns" script. Troubleshoots common setup errors: USER_PERMISSION_DENIED, login_customer_id issues, and DEVELOPER_TOKEN_NOT_APPROVED. Use this skill when: - The user asks how to get started with the Google Ads API. - The user needs to set up Google Ads credentials or developer tokens. - The user wants to write a quickstart/example script for Google Ads. - The user encounters errors like USER_PERMISSION_DENIED or DEVELOPER_TOKEN_NOT_APPROVED.

Use this Skill: https://skilld.dev/gh/google/skills/google-ads-api-quickstart

This session only. Nothing lands on disk.

referencesperl.md

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

Google Ads API Perl Setup Reference

This guide outlines how to configure, install, and write your first Google Ads API call using Perl.

Prerequisites

Step 1: Installation

Install the library:

cpanm Google::Ads::GoogleAds::Client

Step 2: Configuration (googleads.properties)

Create your configuration file named googleads.properties.

When instantiating the client via Client->new(), the Perl client library resolves the configuration file path in the following order:

  1. An explicit path passed directly to Client->new({properties_file => '/path/to/googleads.properties'}).
  2. The location specified in the GOOGLE_ADS_CONFIGURATION_FILE_PATH environment variable, if set.
  3. Otherwise, the default googleads.properties file located in your user's home directory ($HOME).

For self-contained project environments, it is best practice to keep this file in your project root directory and load it explicitly.

# googleads.properties
developer_token=INSERT_DEVELOPER_TOKEN_HERE
client_id=INSERT_OAUTH2_CLIENT_ID_HERE
client_secret=INSERT_OAUTH2_CLIENT_SECRET_HERE
refresh_token=INSERT_OAUTH2_REFRESH_TOKEN_HERE
# login_customer_id=INSERT_LOGIN_CUSTOMER_ID_HERE

Step 3: Write and Run the Quickstart Script

Create get_campaigns.pl:

use strict;
use warnings;
use Google::Ads::GoogleAds::Client;
use Google::Ads::GoogleAds::Utils::SearchStreamHandler;

my $customer_id = $ARGV[0];
$customer_id =~ s/-//g;

# Determine configuration file path (prefer local workspace config)
my $local_config = "./googleads.properties";
my $client;

if (-e $local_config) {
    # Load explicitly from local workspace
    $client = Google::Ads::GoogleAds::Client->new({properties_file => $local_config});
} else {
    # Fallback to default search paths (GOOGLE_ADS_CONFIGURATION_FILE_PATH environment variable or $HOME/googleads.properties)
    $client = Google::Ads::GoogleAds::Client->new();
}

# Load any overriding configuration from environment variables
$client->configure_from_environment_variables();

my $query = "SELECT campaign.id, campaign.name, campaign.status FROM campaign ORDER BY campaign.id";

my $search_stream_handler = Google::Ads::GoogleAds::Utils::SearchStreamHandler->new({
    client => $client,
    customer_id => $customer_id,
    query => $query
});

$search_stream_handler->process(sub {
    my $row = shift;
    printf "Campaign found: ID = %s, Name = '%s', Status = %s\n",
        $row->{campaign}{id},
        $row->{campaign}{name},
        $row->{campaign}{status};
});

Run the script (replace XXXXXXXXXX with your 10-digit Client Customer ID):

perl get_campaigns.pl XXXXXXXXXX

Source: SKILL.md on GitHub

1 warning8d3 checks · Risk SAFE
  • Gen Agent Trust Hub8d

    This skill provides a secure and comprehensive guide for developers to integrate with the Google Ads API. It emphasizes the use of official libraries, dynamic version resolution from trusted sources, and secure credential management practices.

  • Socket8d

    No alerts

  • Snyk8d

    Risk: MEDIUM · 2 issues

Signed by skilld at 329fa26. 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
Other metadata
compatibility
Outbound HTTPS connectivity required to access the Google Ads API and documentation. Note: If network access is restricted, the agent will fall back to using the last-known stable versions cached within the skill resources.
metadata
{
  "author": "google-ads-api-team",
  "version": "1.0.0",
  "category": "GoogleAds"
}

README badge

README badge for google/skills/google-ads-api-quickstart