オーディエンスのエクスポートを作成する
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Google アナリティクスのオーディエンスを使用すると、ビジネスの目的に合わせてユーザーをセグメント化できます。オーディエンスを使用すると、共有属性に基づいてサイトまたはアプリのユーザーをグループ化できます。
Data API を使用して、ユーザーのスナップショットを含むオーディエンスをエクスポートできます。
オーディエンス エクスポートに表示されるデータに関する重要な情報については、オーディエンス エクスポート データの想定内容ガイドをご覧ください。
概要
次の Data API リクエストを実行して、オーディエンス エクスポートを作成してクエリを実行します。
audienceExports.create
メソッドを呼び出して、オーディエンスのエクスポートを作成します。
audienceExports.query
メソッドを呼び出して、オーディエンスのユーザーを取得します。
詳細については、audienceExports.get
を呼び出して特定のオーディエンス エクスポートに関する構成メタデータを取得し、audienceExports.list
を呼び出して特定のプロパティのオーディエンス エクスポートをすべて一覧表示します。
レポート対象エンティティを選択する
すべての Data API メソッドでは、Google アナリティクス プロパティ ID を URL リクエスト パス内に properties/GA_PROPERTY_ID
の形式で指定する必要があります。次の例をご覧ください。
POST https://analyticsdata.googleapis.com/v1beta/properties/GA_PROPERTY_ID/audienceExports
このレポートは、指定した Google アナリティクス プロパティで収集された Google アナリティクスのイベントデータに基づいて生成されます。
Data API クライアント ライブラリのいずれかを使用している場合は、リクエスト URL パスを変更する必要はありません。ほとんどの API クライアントでは、文字列が properties/GA_PROPERTY_ID
の形式の property
パラメータが提供されています。クライアント ライブラリの使用例については、クイック スタートガイドをご覧ください。
オーディエンス エクスポートを作成する
オーディエンス エクスポートを作成するには、リクエストの AudienceExport
オブジェクトを使用して audienceExports.create
メソッドを呼び出します。次のパラメータを指定します。
audience
フィールドに、properties/{propertyId}/audiences/{audienceId}
の形式で有効なオーディエンス名を指定します。この値を取得するには、Google Analytics Admin API v1 の audiences.list
メソッドを使用します。audiences.list
レスポンスの Audience.name
フィールドには、オーディエンス名が含まれます。
dimensions
フィールドの有効なディメンションのリスト。このメソッドでサポートされているディメンションのリストについては、オーディエンス エクスポート スキーマのドキュメントをご覧ください。オーディエンス エクスポートには、このフィールドに記載されているディメンションのデータのみが含まれます。
オーディエンス エクスポートを作成するリクエストの例を次に示します。
HTTP リクエスト
POST https://analyticsdata.googleapis.com/v1beta/properties/1234567/audienceExports
{
"audience": "properties/1234567/audiences/12345",
"dimensions": [
{
"dimensionName": "deviceId"
}
]
}
audienceExports.create
メソッドのレスポンスの name
フィールドには、オーディエンス エクスポートの名前(properties/1234567/audienceExports/123
など)が含まれます。レスポンスの例を次に示します。
HTTP レスポンス
{
"response": {
"@type": "type.googleapis.com/google.analytics.data.v1alpha.AudienceExport",
"name": "properties/1234567/audienceExports/123",
"audience": "properties/1234567/audiences/12345",
"audienceDisplayName": "Purchasers",
"dimensions": [
{
"dimensionName": "deviceId"
}
],
"state": "CREATING",
"beginCreatingTime": "2023-06-22T23:35:28.787910949Z"
}
}
name
を使用すると、オーディエンス エクスポートのユーザーをクエリできます。
オーディエンス エクスポートの準備状況をクエリする
audienceExports.create
呼び出し後にオーディエンス エクスポートが生成されるまで、数分かかることがあります。
オーディエンス エクスポートの準備状況を確認するには、audienceExports.get
メソッドを呼び出します。
audienceExports.create
レスポンスからオーディエンス エクスポート名を使用して、リクエストでオーディエンス エクスポートを指定します。
リクエストの例を次に示します。
HTTP リクエスト
GET https://analyticsdata.googleapis.com/v1beta/properties/1234567/audienceExports/123
オーディエンス エクスポートの準備状況は、レスポンスの state
フィールドに返されます。オーディエンス エクスポートの生成が完了すると、ステータスが CREATING
から ACTIVE
に変わります。
レスポンスの例を次に示します。
HTTP レスポンス
{
"name": "properties/1234567/audienceExports/123",
"audience": "properties/1234567/audiences/12345",
"audienceDisplayName": "Purchasers",
"dimensions": [
{
"dimensionName": "deviceId"
}
],
"state": "CREATING",
"beginCreatingTime": "2023-06-22T23:35:28.787910949Z"
}
すべてのオーディエンス エクスポートのステータスを取得するには、audienceExports.list
メソッドを呼び出します。
オーディエンス エクスポートからユーザーを取得する
オーディエンス エクスポートが生成されたら、audienceExports.query
メソッドを呼び出し、リクエストにオーディエンス エクスポートの name
を指定します。
リクエストの例を次に示します。
HTTP リクエスト
POST https://analyticsdata.googleapis.com/v1beta/properties/1234567/audienceExports/123:query
オーディエンスのエクスポートの準備が整うと、この呼び出しはオーディエンス内のユーザーのリストを返します。
レスポンスの例を次に示します。
HTTP レスポンス
{
"audienceExport": {
"name": "properties/1234567/audienceExports/123",
"audience": "properties/1234567/audiences/12345",
"audienceDisplayName": "Purchasers",
"dimensions": [
{
"dimensionName": "deviceId"
}
],
"state": "ACTIVE",
"beginCreatingTime": "2023-06-22T23:35:28.787910949Z"
},
"audienceRows": [
{
"dimensionValues": [
{
"value": "1000276123.1681742376"
}
]
},
{
"dimensionValues": [
{
"value": "1000374452.1668627377"
}
]
},
{
"dimensionValues": [
{
"value": "1000391956.1652750758"
}
]
},
{
"dimensionValues": [
{
"value": "1000410539.1682018694"
}
]
},
{
"dimensionValues": [
{
"value": "1000703969.1666725875"
}
]
}
],
"rowCount": 5
}
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-07-26 UTC。
[null,null,["最終更新日 2025-07-26 UTC。"],[[["\u003cp\u003eGoogle Analytics Audiences allows you to segment users based on shared attributes, enabling targeted analysis and marketing efforts.\u003c/p\u003e\n"],["\u003cp\u003eYou can export audience data, including user snapshots, using the Data API, specifically the \u003ccode\u003eaudienceExports.create\u003c/code\u003e and \u003ccode\u003eaudienceExports.query\u003c/code\u003e methods.\u003c/p\u003e\n"],["\u003cp\u003eBefore querying, you should check the audience export's readiness state using the \u003ccode\u003eaudienceExports.get\u003c/code\u003e method to ensure data is available.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eaudienceExports.list\u003c/code\u003e method lets you view all your audience exports for a given property, while \u003ccode\u003eaudienceExports.query\u003c/code\u003e retrieves the actual user data.\u003c/p\u003e\n"]]],["Google Analytics audiences can be segmented and exported via the Data API. To export, first, call `audienceExports.create` with a valid audience name and dimensions. Then, use `audienceExports.get` to check the export's readiness (`CREATING` or `ACTIVE`). Once `ACTIVE`, retrieve users with `audienceExports.query` using the export's name. You can use `audienceExports.list` to view all exports and use the format `properties/GA_PROPERTY_ID` when specifying the property ID.\n"],null,["# Create an audience export\n\n[Audiences in Google Analytics](//support.google.com/analytics/answer/9267572)\nlet you segment your users in the ways that are important to your business. With\naudiences, you can group users of your site or application based on shared\nattributes.\n\nYou can export your audiences, including a snapshot of their users, using the\n[Data API](/analytics/devguides/reporting/data/v1/rest).\n\nRefer to the [Audience export data expectations](/analytics/devguides/reporting/data/v1/audience-export-expectations)\nguide for important information about the data you see in audience exports.\n\nOverview\n--------\n\nMake the following Data API requests to create and query an audience export:\n\n1. Call the [`audienceExports.create`](/analytics/devguides/reporting/data/v1/rest/v1beta/properties.audienceExports/create) method to create an audience export.\n2. Call the [`audienceExports.query`](/analytics/devguides/reporting/data/v1/rest/v1beta/properties.audienceExports/query) method is used to retrieve the users in the audience.\n\nFor more information, you can call\n[`audienceExports.get`](/analytics/devguides/reporting/data/v1/rest/v1beta/properties.audienceExports/get) to\nretrieve configuration metadata about a specific audience export, and\n[`audienceExports.list`](/analytics/devguides/reporting/data/v1/rest/v1beta/properties.audienceExports/list) to\nlist all your audience exports for a specific property.\n\nSelect a reporting entity\n-------------------------\n\nAll Data API methods require the [Google Analytics property\nidentifier](/analytics/devguides/reporting/data/v1/property-id) to be specified inside a URL request path, in the\nform of `properties/GA_PROPERTY_ID`. Here's an example: \n\n POST https://analyticsdata.googleapis.com/v1beta/properties/GA_PROPERTY_ID/audienceExports\n\nThe report is generated based on the Google Analytics event data collected in\nthe specified Google Analytics property.\n\nIf you're using one of the [Data API client libraries](/analytics/devguides/reporting/data/v1/client-libraries), you\ndon't need to change the request URL path. Most API clients provide a `property`\nparameter that expects a string in the form of `properties/GA_PROPERTY_ID`. See\n[Quick start guide](/analytics/devguides/reporting/data/v1/quickstart-client-libraries) for examples of using the\nclient libraries.\n\nCreate an audience export\n-------------------------\n\nTo create an audience export, call the [`audienceExports.create`](/analytics/devguides/reporting/data/v1/rest/v1beta/properties.audienceExports/create) method using the\n[`AudienceExport`](/analytics/devguides/reporting/data/v1/rest/v1beta/properties.audienceExports#AudienceExport)\nobject in your request. The following parameters are required:\n\n- A valid audience name in the [`audience`](/analytics/devguides/reporting/data/v1/rest/v1beta/properties.audienceExports#AudienceExport.FIELDS.audience) field, formatted as `properties/{propertyId}/audiences/{audienceId}`. You can use the [`audiences.list`](/analytics/devguides/config/admin/v1/rest/v1alpha/properties.audiences/list) method of the Google Analytics Admin API v1 to obtain this value. The [`Audience.name`](/analytics/devguides/config/admin/v1/rest/v1alpha/properties.audiences#Audience.FIELDS.name) field of the `audiences.list` response contains the audience name.\n- A valid list of dimensions in the [`dimensions`](/analytics/devguides/reporting/data/v1/rest/v1beta/properties.audienceExports#AudienceExport.FIELDS.dimensions) field. The list of dimensions supported by this method can be found in the [Audience export schema](/analytics/devguides/reporting/data/v1/audience-export-api-schema) documentation. Only the data for dimensions mentioned in this field is included in an audience export.\n\nHere's a sample request to create an audience export: \n\n### HTTP Request\n\n POST https://analyticsdata.googleapis.com/v1beta/properties/1234567/audienceExports\n {\n \"audience\": \"properties/1234567/audiences/12345\",\n \"dimensions\": [\n {\n \"dimensionName\": \"deviceId\"\n }\n ]\n }\n\nA response of the `audienceExports.create` method contains the audience export's\nname in the `name` field, for example `properties/1234567/audienceExports/123`.\nHere's a sample response: \n\n### HTTP Response\n\n {\n \"response\": {\n \"@type\": \"type.googleapis.com/google.analytics.data.v1alpha.AudienceExport\",\n \"name\": \"properties/1234567/audienceExports/123\",\n \"audience\": \"properties/1234567/audiences/12345\",\n \"audienceDisplayName\": \"Purchasers\",\n \"dimensions\": [\n {\n \"dimensionName\": \"deviceId\"\n }\n ],\n \"state\": \"CREATING\",\n \"beginCreatingTime\": \"2023-06-22T23:35:28.787910949Z\"\n }\n }\n\nYou can use the `name` to query the users from the audience export.\n\nQuery the audience export's readiness state\n-------------------------------------------\n\nIt might take several minutes to generate the audience export after the\n[`audienceExports.create`](/analytics/devguides/reporting/data/v1/rest/v1beta/properties.audienceExports/create)\ncall.\n\nYou can check the readiness state of an audience export by calling the\n[`audienceExports.get`](/analytics/devguides/reporting/data/v1/rest/v1beta/properties.audienceExports/get) method.\n\nUse the audience export name from an `audienceExports.create` response to\nspecify the audience export in your request.\n\nHere's a sample request: \n\n### HTTP Request\n\n GET https://analyticsdata.googleapis.com/v1beta/properties/1234567/audienceExports/123\n\nThe readiness state for an audience export is returned in the [`state`](/analytics/devguides/reporting/data/v1/rest/v1beta/properties.audienceExports#AudienceExport.FIELDS.state) field\nof the response. Once the audience export generation is complete, its state\nchanges from `CREATING` to `ACTIVE`.\n\nHere's a sample response: \n\n### HTTP Response\n\n {\n \"name\": \"properties/1234567/audienceExports/123\",\n \"audience\": \"properties/1234567/audiences/12345\",\n \"audienceDisplayName\": \"Purchasers\",\n \"dimensions\": [\n {\n \"dimensionName\": \"deviceId\"\n }\n ],\n \"state\": \"CREATING\",\n \"beginCreatingTime\": \"2023-06-22T23:35:28.787910949Z\"\n }\n\nYou can obtain the state of all audience exports by calling the\n[`audienceExports.list`](/analytics/devguides/reporting/data/v1/rest/v1beta/properties.audienceExports/list)\nmethod.\n\nRetrieve users from an audience export\n--------------------------------------\n\nOnce the audience export is generated, call the [`audienceExports.query`](/analytics/devguides/reporting/data/v1/rest/v1beta/properties.audienceExports/query) method, and specify the\naudience export's `name` in the request.\n\nHere's a sample request: \n\n### HTTP Request\n\n POST https://analyticsdata.googleapis.com/v1beta/properties/1234567/audienceExports/123:query\n\nIf the audience export is ready, this call returns the list of users in the\naudience.\n\nHere's a sample response: \n\n### HTTP Response\n\n {\n \"audienceExport\": {\n \"name\": \"properties/1234567/audienceExports/123\",\n \"audience\": \"properties/1234567/audiences/12345\",\n \"audienceDisplayName\": \"Purchasers\",\n \"dimensions\": [\n {\n \"dimensionName\": \"deviceId\"\n }\n ],\n \"state\": \"ACTIVE\",\n \"beginCreatingTime\": \"2023-06-22T23:35:28.787910949Z\"\n },\n \"audienceRows\": [\n {\n \"dimensionValues\": [\n {\n \"value\": \"1000276123.1681742376\"\n }\n ]\n },\n {\n \"dimensionValues\": [\n {\n \"value\": \"1000374452.1668627377\"\n }\n ]\n },\n {\n \"dimensionValues\": [\n {\n \"value\": \"1000391956.1652750758\"\n }\n ]\n },\n {\n \"dimensionValues\": [\n {\n \"value\": \"1000410539.1682018694\"\n }\n ]\n },\n {\n \"dimensionValues\": [\n {\n \"value\": \"1000703969.1666725875\"\n }\n ]\n }\n ],\n \"rowCount\": 5\n }"]]