ウェブテスト: insert

承認が必要です

新しいウェブテストを作成します。 例をご覧ください

標準パラメータに加えて、このメソッドはパラメータ表のリストにあるパラメータをサポートしています。

リクエスト

HTTP リクエスト

POST https://www.googleapis.com/analytics/v3/management/accounts/accountId/webproperties/webPropertyId/profiles/profileId/experiments

パラメータ

パラメータ名 説明
パスパラメータ
accountId string ウェブテストを作成するためのアカウント ID。
profileId string ウェブテストを作成するためのビュー(旧プロファイル)の ID。
webPropertyId string ウェブテストを作成するためのウェブ プロパティ ID。

承認

このリクエストは、少なくとも以下のスコープの 1 つによって承認される必要があります(詳細については、認証と承認に関する記事をご覧ください)。

スコープ
https://www.googleapis.com/auth/analytics
https://www.googleapis.com/auth/analytics.edit

リクエスト本文

リクエストの本文では、次のプロパティで management.experiment resource を指定します。

プロパティ名 説明 備考
必須プロパティ
name string ウェブテストの名前。ウェブテストのステータスが ENDED の場合は、このフィールドは変更されません。ウェブテストを作成する場合はこのフィールドが必須です。 書き込み可能
status string ウェブテストのステータス。有効な値は「DRAFT」、「READY_TO_RUN」、「RUNNING」、「ENDED」です。「DRAFT」、「READY_TO_RUN」、「RUNNING」のいずれかの状態でウェブテストを作成できます。ウェブテストを作成する場合、このフィールドは必須です。 書き込み可能
variations[].name string パターンの名前。ウェブテストを作成する場合、このフィールドは必須です。ウェブテストのステータスが ENDED の場合は、このフィールドは変更されません。 書き込み可能
省略可能なプロパティ
description string このウェブテストの備考。 書き込み可能
editableInGaUi boolean true の場合、エンドユーザーは Google アナリティクスの管理画面を介してウェブテストを編集することができます。 書き込み可能
equalWeighting boolean すべてのパターンにトラフィックを均等に分配するかどうかを指定するブール値。値が False の場合、コンテンツのウェブテストはパターンの成果に基づいて動的にトラフィックを調整するデフォルトの動作を行います。省略可能で、デフォルトは False です。ウェブテストのステータスが ENDED の場合は、このフィールドは変更されません。 書き込み可能
minimumExperimentLengthInDays integer [3、90] の整数値。ウェブテストの最短時間を指定します。ウェブテストが実行中の場合に変更できます。ウェブテストのステータスが ENDED の場合は、このフィールドは変更されません。 書き込み可能
objectiveMetric string ウェブテストにより最適化される指標。有効な値は、「ga:goal(n)Completions」、「ga:adsenseAdsClicks」、「ga:adsenseAdsViewed」、「ga:adsenseRevenue」、「ga:bounces」、「ga:pageviews」、「ga:sessionDuration」、「ga:transactions」、「ga:transactionRevenue」です。ステータスが「RUNNING」で servingFramework が「REDIRECT」または「API」のいずれかである場合、このフィールドは必須です。 書き込み可能
optimizationType string objectiveMetric を最小化または最大化する必要があるかどうかを指定します。有効な値は「MAXIMUM」と「MINIMUM」です。省略可能で、デフォルトは「MAXIMUM」です。objectiveMetric なしで指定することはできません。また、ステータスが「RUNNING」または「ENDED」の場合は変更できません。 書き込み可能
rewriteVariationUrlsAsOriginal boolean パターンの URL が元の URL と一致するように上書きされるかどうかを指定するブール値。ウェブテストのステータスが ENDED の場合は、このフィールドは変更されません。 書き込み可能
servingFramework string ウェブテスト パターンの配信と結果の評価に使用するフレームワーク。次のいずれかです。
  • REDIRECT: Google アナリティクスでは、パターンが異なるページへのトラフィックをリダイレクトし、選択したパターンを報告し、その結果を評価します。
  • API: Google アナリティクスでは、配信するパターンを選択して報告し、その結果を評価します。発信者は、選択したパターンを配信する必要があります。
  • EXTERNAL: パターンを外部に配信し、選択したパターンを Google アナリティクスに報告します。発信者は、選択したパターンを配信し、結果を評価する必要があります。
書き込み可能
trafficCoverage double 0~1 の浮動小数点数。ウェブテストに参加するトラフィックの割合を指定します。ウェブテストが実行中の場合に変更できます。ウェブテストのステータスが ENDED の場合は、このフィールドは変更されません。 書き込み可能
variations[] list パターンの配列。配列の最初のパターンはオリジナルです。ウェブテストの状態が「RUNNING」に変わると、パターンの数を変更することはできません。ステータスを「RUNNING」に設定できるようにするには、少なくとも 2 つのパターンが必要です。 書き込み可能
variations[].status string パターンのステータス。有効な値は「ACTIVE」と「INACTIVE」です。「INACTIVE」のパターンは配信されません。ウェブテストのステータスが ENDED の場合は、このフィールドは変更されません。 書き込み可能
variations[].url string パターンの URL。ウェブテストのステータスが RUNNING か ENDED の場合は、このフィールドは変更されません。 書き込み可能
winnerConfidenceLevel double 0~1 の浮動小数点数。最も掲載結果の高い組み合わせを選択する際の、必要な信頼度を指定します。ウェブテストのステータスが ENDED の場合は、このフィールドは変更されません。 書き込み可能

レスポンス

正常終了した場合、このメソッドによって management.experiment リソースを含むレスポンスの本文が返されます。

注: このメソッドで使用可能なコード例では、サポートされているプログラミング言語すべての例を示しているわけではありません(サポートされている言語の一覧については、クライアント ライブラリ ページをご覧ください)。

Java

Java クライアント ライブラリを使用します。

/*
 * Note: This code assumes you have an authorized Analytics service object.
 * See the Experiments Developer Guide for details.
 */

/*
 *  This request creates a new Experiment.
 */

// Construct the body of the request.
Experiment body = new Experiment();
body.setName("Landing Page Experiment");
body.setStatus("DRAFT");

// Construct the first variation.
Variations variationA = new Variations();
variationA.setName("Variation A");
variationA.setUrl("index.html");

// Construct the second variation.
Variations variationB = new Variations();
variationB.setName("Variation B");
variationB.setUrl("indexB.html");

// Set the variations.
body.setVariations(Arrays.asList(variationA, variationB));

try {
  analytics.management().experiments().insert("123456", "UA-123456-1",
      "7654321", body).execute();
} catch (GoogleJsonResponseException e) {
  System.err.println("There was a service error: "
      + e.getDetails().getCode() + " : "
      + e.getDetails().getMessage());
}

PHP

PHP クライアント ライブラリを使用します。

/**
 * Note: This code assumes you have an authorized Analytics service object.
 * See the Experiments Developer Guide for details.
 */

/**
 * This request creates a new experiment.
 */

// Construct the body of the request.
$experiment = new Google_Service_Analytics_Experiment();
$experiment->setName('Landing Page Experiment');
$experiment->setStatus('DRAFT');

// Construct the first variation.
$variationA = new Google_Service_Analytics_ExperimentVariations();
$variationA->setName('VariationA');
$variationA->setUrl('index.html');

// Construct the second variation.
$variationB = new Google_Service_Analytics_ExperimentVariations();
$variationB->setName('VariationB');
$variationB->setUrl('indexB.html');

// Set the variations.
$experiment->setVariations(array($variationA, $variationB));

try {
  $analytics->management_experiments->insert('123456', 'UA-123456-1',
      '7654321', $experiment);
} catch (apiServiceException $e) {
  print 'There was an Analytics API service error '
      . $e->getCode() . ':' . $e->getMessage();

} catch (apiException $e) {
  print 'There was a general API error '
      . $e->getCode() . ':' . $e->getMessage();
}

Python

Python クライアント ライブラリを使用します。

# Note: This code assumes you have an authorized Analytics service object.
# See the Experiments Developer Guide for details.

# Example #1:
# Creates a new DRAFT experiment with two variations.
try:
  experiments = analytics.management().experiments().insert(
      accountId='123456',
      webPropertyId='UA-123456-1',
      profileId='98765432',
      body={
          'name': 'Landing Page Test',
          'status': 'DRAFT',
          'variations': [
              {
                  'name': 'Variation A',
                  'url': 'index.html'
              },
              {
                  'name': 'Variation B',
                  'url': 'indexB.html'
              }
          ]
      }
  ).execute()

except TypeError, error:
  # Handle errors in constructing a query.
  print 'There was an error in constructing your query : %s' % error

except HttpError, error:
  # Handle API errors.
  print ('There was an API error : %s : %s' %
         (error.resp.status, error.resp.reason))

JavaScript

JavaScript クライアント ライブラリを使用します。

/*
 * Note: This code assumes you have an authorized Analytics client object.
 * See the Experiments Developer Guide for details.
 */

/*
 * This request creates a new Experiment.
 */
function insertExperiment() {
  var request = gapi.client.analytics.management.experiments.insert(
    {
      'accountId': '123456',
      'webPropertyId': 'UA-123456-1',
      'profileId': '7654321',
      'resource': {
        'name': 'Landing Page Test',
        'status': 'DRAFT',
        'variations': [
          {
            'name': 'VariationA',
            'url': 'index.html'
          },
          {
            'name': 'VariationB',
            'url': 'indexB.html'
          }
        ]
      }
    });
  request.execute(function (response) { // Handle the response. });
}