Peter Pan
Peter Pan

Reputation: 55

Where to find accountId and adClientId in AdSense account?

I am new using the AdSense API, but i really need to use it :)

I am trying to use Accounts.customchannels: get

Where can i find accountId and adClientId in AdSense account?

When i access to Account information i can see:

Publisher ID: pub-xxxxxxxxxxx and Customer ID: xxxxxxxx

Is this the information that i need? Which one is the accountId and the adClientId?

I already tryed to insert this values in diffrent ways, but the result is always:

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "notFound",
    "message": "Ad client not found.",
    "locationType": "parameter",
    "location": "adClientId"
   }
  ],
  "code": 404,
  "message": "Ad client not found."
 }
}

Thank you all.

Upvotes: 0

Views: 558

Answers (2)

Al Azad
Al Azad

Reputation: 51

this will show you account id usally it's "accounts/pub-******"

/**
 * Lists available AdSense accounts.
 */
function listAccounts() {
  let pageToken;
  do {
    const response = AdSense.Accounts.list({pageToken: pageToken});
    if (!response.accounts) {
      Logger.log('No accounts found.');
      return;
    }
    for (const account of response.accounts) {
      Logger.log('Found account with resource name "%s" and display name "%s".',
          account.name, account.displayName);
    }
    pageToken = response.nextPageToken;
  } while (pageToken);
}

Upvotes: 0

Donovan McMurray
Donovan McMurray

Reputation: 199

There are some other AdSense API methods that will give you the fields you're looking for.

Accounts: list will return the list of Accounts you have access to. The id field will correspond to the accountId field you're looking for.

Accounts.adclients: list will return the list of AdClients for a given account (use accountId from the previous step). The id field will correspond to the adClientId field.

Upvotes: 0

Related Questions