> ## Documentation Index
> Fetch the complete documentation index at: https://www.ayrshare.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# インサイト

> キャンペーン、広告グループ、広告ごとに、クリック数、費用、コンバージョン、コンバージョン値を含む Google Ads の日次指標をリアルタイムで取得します。

Ayrshare で作成したキャンペーン、広告グループ、または広告について、Google Ads のパフォーマンスを1日1行でリアルタイムに取得します。

<ul>
  <li>数値は夜間に作成されたコピーではなく、呼び出し時に Google から読み取られます。</li>
  <li>すべての金額は広告アカウントの通貨で表され、各行の `currency` で返されます。</li>
  <li>Google はアクティビティのない日を省略するため、期間の日数より少ない行が返されることがあります。</li>
  <li>Google は、日が終わってから数日間はその日の費用とコンバージョンを調整するため、直近の日の数値は読み取るたびに変わることがあります。</li>
  <li>Performance Max キャンペーンの場合は、キャンペーン ID とともに `level=campaign` を使用してください。Performance Max キャンペーンには独自の広告がないため、`level=ad` では行が返されません。</li>
</ul>

## ヘッダーパラメータ

**Authorization** `string` *required*

[API Key](https://www.ayrshare.com/docs/apis/overview.md#authorization) of the Primary Profile.

Format: `Authorization: Bearer API_KEY`
**Profile-Key** `string`

[Profile Key](https://www.ayrshare.com/docs/apis/overview.md#profile-key-format) of a User Profile.

Format: `Profile-Key: PROFILE_KEY`

## クエリパラメータ

**level** `string` *required*

各行のレポート対象: `campaign`(作成時の `campaignId`)、`adSet`(作成時の `adGroupId`)、または `ad`(作成時の `adId`)。

**ids** `string` *required*

カンマ区切りのキャンペーン ID、広告グループ ID、または広告 ID(最大50件)。すべて1つの広告アカウント内にある必要があります。

**accountId** `string`

10桁の Google Ads お客様 ID。ハイフンの有無は問いません(`123-456-7890`)。

広告と広告グループのレポートは、ここで指定した広告アカウントを読み取ります。指定しない場合、広告レポートは Google Ads の連携でアクセスできるすべての広告アカウント(最大25件)を検索し、広告グループレポートは連携でアクセスできる広告アカウントが1つの場合にのみ機能します。連携でアクセスできる広告アカウントが25件を超える場合、または広告グループレポートで2件以上ある場合は、アカウントを指定してください。指定しないと `code: 101` が返されます。

**metrics** `string`

返す指標をカンマ区切りで指定します。省略するとすべての指標が返されます。[指標](#metrics)を参照してください。

**startDate** `string` (default: 30日前)

開始日(`YYYY-MM-DD`形式)。Google は日次の数値を37か月間保持します。それより前の `startDate` を指定すると `code: 101` が返されます。

**endDate** `string` (default: 今日)

終了日(`YYYY-MM-DD`形式)。

## 指標

| 指標 | 型 | 意味 |
| - | - | - |
| `spend` | number | 出稿費用 |
| `impressions` | number | 広告が表示された回数 |
| `clicks` | number | クリック数 |
| `cpm` | numberまたは`null` | 1,000インプレッションあたりのコスト。インプレッションがない日は`null` |
| `cpc` | numberまたは`null` | クリック単価。クリックがない日は`null` |
| `ctr` | numberまたは`null` | クリック率(パーセント)。インプレッションがない日は`null` |
| `actions` | number | Google のコンバージョン数。小数になることがあります |
| `conversionValue` | number | それらのコンバージョンの値 |

`actions` と `conversionValue` は、Google Ads アカウントでコンバージョン トラッキングを設定するまで `0` のままです。Google は検索のユニークリーチを報告しないため `reach` は利用できず、Google では `breakdowns` も利用できません。どちらかをリクエストすると `code: 101` が返されます。

## ページング

すべての行が1つのレスポンスで返されるため、`nextCursor` は常に `null` です。

## エラー

| コード | 発生条件 |
| - | - |
| `101` | パラメータが不足しているか誤っている、指標または内訳がサポートされていない、`startDate`が37か月より前である、50件を超えるIDが送信された、IDが複数の広告アカウントにまたがっている、または`accountId`が必要なのに指定されていない |
| `400` | キャンペーン、広告グループ、または広告がお客様のものではない、または`accountId`が、送信したIDについてAyrshareが記録している広告アカウントと一致しない |
| `370` | Googleがインサイトを返せませんでした。再度お試しください |

```bash cURL theme={"system"}
curl \
-H "Authorization: Bearer API_KEY" \
-X GET "https://api.ayrshare.com/api/ads/google/insights?level=campaign&ids=21534567890&startDate=2026-10-01&endDate=2026-10-07"
```

```javascript JavaScript theme={"system"}
const API_KEY = "API_KEY";

fetch("https://api.ayrshare.com/api/ads/google/insights?level=campaign&ids=21534567890&startDate=2026-10-01&endDate=2026-10-07", {
  method: "GET",
  headers: {
    "Authorization": `Bearer ${API_KEY}`
  }
})
  .then((res) => res.json())
  .then((json) => console.log(json))
  .catch(console.error);
```

```python Python theme={"system"}
import requests

headers = {
    "Authorization": "Bearer API_KEY",
}

r = requests.get("https://api.ayrshare.com/api/ads/google/insights?level=campaign&ids=21534567890&startDate=2026-10-01&endDate=2026-10-07", headers=headers)

print(r.json())
```

```php PHP theme={"system"}
<?php
$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => "https://api.ayrshare.com/api/ads/google/insights?level=campaign&ids=21534567890&startDate=2026-10-01&endDate=2026-10-07",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer API_KEY"
    ]
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
    echo "cURL Error: " . $err;
} else {
    echo $response;
}
?>
```

```csharp C# theme={"system"}
using System;
using System.Net.Http;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        var client = new HttpClient();
        client.DefaultRequestHeaders.Add("Authorization", "Bearer API_KEY");

        var response = await client.GetAsync("https://api.ayrshare.com/api/ads/google/insights?level=campaign&ids=21534567890&startDate=2026-10-01&endDate=2026-10-07");
        var content = await response.Content.ReadAsStringAsync();

        Console.WriteLine(content);
    }
}
```

```go Go theme={"system"}
package main

import (
    "fmt"
    "io"
    "net/http"
)

func main() {
    req, _ := http.NewRequest("GET", "https://api.ayrshare.com/api/ads/google/insights?level=campaign&ids=21534567890&startDate=2026-10-01&endDate=2026-10-07", nil)
    req.Header.Add("Authorization", "Bearer API_KEY")

    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        fmt.Println("Error:", err)
        return
    }
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
```

```java Java theme={"system"}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class GetAdInsights {
    public static void main(String[] args) throws Exception {
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.ayrshare.com/api/ads/google/insights?level=campaign&ids=21534567890&startDate=2026-10-01&endDate=2026-10-07"))
            .header("Authorization", "Bearer API_KEY")
            .GET()
            .build();

        HttpResponse<String> response = HttpClient.newHttpClient()
            .send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}
```

```ruby Ruby theme={"system"}
require 'net/http'
require 'uri'

uri = URI.parse('https://api.ayrshare.com/api/ads/google/insights?level=campaign&ids=21534567890&startDate=2026-10-01&endDate=2026-10-07')

request = Net::HTTP::Get.new(uri)
request['Authorization'] = 'Bearer API_KEY'

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  http.request(request)
end

puts response.body
```

```json 200: Success theme={"system"}
{
  "status": "success",
  "platform": "google",
  "level": "campaign",
  "startDate": "2026-10-01",
  "endDate": "2026-10-07",
  "insights": [
    {
      "date": "2026-10-01",
      "level": "campaign",
      "id": "21534567890",
      "currency": "USD",
      "spend": 12.48,
      "impressions": 1830,
      "clicks": 41,
      "cpm": 6.82,
      "cpc": 0.3,
      "ctr": 2.2404,
      "actions": 3.5,
      "conversionValue": 140
    }
  ],
  "count": 1,
  "nextCursor": null
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.