AI-generated Key Takeaways
-
This method gets the AdSense code for a given ad client, specifically the auto ad code.
-
This functionality is only supported for ad clients with a product code of AFC.
-
The request uses a GET HTTP method and requires the ad client name as a path parameter.
-
The response body is a JSON object containing the
adCode
,ampHead
, andampBody
snippets. -
The method requires either the
https://www.googleapis.com/auth/adsense
orhttps://www.googleapis.com/auth/adsense.readonly
OAuth scope for authorization.
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 |
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 |
Output only. The AdSense code snippet to add to the head of an HTML page. |
ampHead |
Output only. The AdSense code snippet to add to the head of an AMP page. |
ampBody |
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