Method: accounts.adclients.getAdcode
Stay organized with collections
Save and categorize content based on your preferences.
Gets the AdSense code for a given ad client. This returns what was previously known as the 'auto ad code'.
This is only supported for ad clients with a productCode of AFC.
For more information, see About the AdSense code.
HTTP request
GET https://adsense.googleapis.com/v2/{name=accounts/*/adclients/*}/adcode
The URL uses gRPC Transcoding syntax.
Path parameters
Parameters |
name |
string
Required. Name of the ad client for which to get the adcode. Format: accounts/{account}/adclients/{adclient}
|
Request body
The request body must be empty.
Response body
Representation of the AdSense code for a given ad client.
For more information, see About the AdSense code.
If successful, the response body contains data with the following structure:
JSON representation |
{
"adCode": string,
"ampHead": string,
"ampBody": string
} |
Fields |
adCode |
string
Output only. The AdSense code snippet to add to the head of an HTML page.
|
ampHead |
string
Output only. The AdSense code snippet to add to the head of an AMP page.
|
ampBody |
string
Output only. The AdSense code snippet to add to the body of an AMP page.
|
Authorization scopes
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/adsense
https://www.googleapis.com/auth/adsense.readonly
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-02-28 UTC.
[null,null,["Last updated 2025-02-28 UTC."],[[["\u003cp\u003eRetrieves the AdSense code (previously known as 'auto ad code') for a specified ad client.\u003c/p\u003e\n"],["\u003cp\u003eThis functionality is exclusively available for ad clients possessing a productCode of AFC.\u003c/p\u003e\n"],["\u003cp\u003eThe response provides AdSense code snippets for both HTML and AMP pages, including designated head and body placements for AMP.\u003c/p\u003e\n"],["\u003cp\u003eRequires authorization with specific Google Adsense scopes for access.\u003c/p\u003e\n"]]],["To retrieve the AdSense code for an ad client, a `GET` request is sent to `https://adsense.googleapis.com/v2/{name}/adcode`, where `name` specifies the ad client's ID. The request body must be empty. The response, containing strings representing the AdSense code, `ampHead` and `ampBody`, is returned. It requires authorization with either `adsense` or `adsense.readonly` scopes and only works for ad clients with a product code of AFC.\n"],null,["# Method: accounts.adclients.getAdcode\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n - [JSON representation](#body.AdClientAdCode.SCHEMA_REPRESENTATION)\n- [Authorization scopes](#body.aspect)\n- [Try it!](#try-it)\n\nGets the AdSense code for a given ad client. This returns what was previously known as the 'auto ad code'.\n\nThis is only supported for ad clients with a productCode of AFC.\n\nFor more information, see [About the AdSense code](https://support.google.com/adsense/answer/9274634).\n\n### HTTP request\n\n`GET https://adsense.googleapis.com/v2/{name=accounts/*/adclients/*}/adcode`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|--------|-----------------------------------------------------------------------------------------------------------------------|\n| `name` | `string` Required. Name of the ad client for which to get the adcode. Format: accounts/{account}/adclients/{adclient} |\n\n### Request body\n\nThe request body must be empty.\n\n### Response body\n\nRepresentation of the AdSense code for a given ad client.\n\nFor more information, see [About the AdSense code](https://support.google.com/adsense/answer/9274634).\n\nIf successful, the response body contains data with the following structure:\n\n| JSON representation |\n|--------------------------------------------------------------------|\n| ``` { \"adCode\": string, \"ampHead\": string, \"ampBody\": string } ``` |\n\n| Fields ||\n|-----------|------------------------------------------------------------------------------------|\n| `adCode` | `string` Output only. The AdSense code snippet to add to the head of an HTML page. |\n| `ampHead` | `string` Output only. The AdSense code snippet to add to the head of an AMP page. |\n| `ampBody` | `string` Output only. The AdSense code snippet to add to the body of an AMP page. |\n\n### Authorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `https://www.googleapis.com/auth/adsense`\n- `\n https://www.googleapis.com/auth/adsense.readonly`"]]