ウェブテスト: update

承認が必要です

既存のウェブテストを更新します。 例をご覧ください

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

リクエスト

HTTP リクエスト

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

パラメータ

パラメータ名 説明
パスパラメータ
accountId string 更新するウェブテストのアカウント ID。
experimentId 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 を指定します。

プロパティ名 説明 備考
必須プロパティ
id string ウェブテストの ID。パッチの適用と更新の場合の必須 ID です。作成の場合は使用できません。
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 example updates an existing experiment with new variations.
Variations variationA = new Variations();
variationA.setName("Home Alpha");
variationA.setUrl("homeA.html");
Variations variationB = new Variations();
variationB.setName("Home Beta");
variationB.setUrl("homeB.html");
List<Variations> variations = Arrays.asList(variationA, variationB);

try {
  // First get an existing Experiment.
  Experiment body = analytics.management().experiments().get("123456",
      "UA-123456-1", "7654321", "122333444455555").execute();

  // Set the new variations.
  body.setVariations(variations);

  // Call Update with the updated experiment.
  analytics.management().experiments().update("123456", "UA-123456-1",
      "7654321", "122333444455555", 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 updates an existing experiment.
 */

// 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');

try {
  // Get an existing Experiment.
  $experiment = $analytics->management_experiments->get('123456',
      'UA-123456-1', '7654321', '122333444455555');

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

  // Call the update method with the updated experiment.
  $analytics->management_experiments->update('123456', 'UA-123456-1',
      '7654321', '122333444455555', $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.

# This request updates an existing experiment with a new name,
# and new variations.
try:
  analytics.management().experiments().update(
      accountId='123456',
      webPropertyId='UA-123456-1',
      profileId='7654321',
      experimentId='ABCDEFG123456abcdefg',
      body={
          'name': 'Updated Test Title',
          'status': 'DRAFT',
          'variations': [
              {
                  'name': 'Checkout Page',
                  'url': 'checkout.html'
              },
              {
                  'name': 'Proposed Checkout Page',
                  'url': 'newCheckout.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 updates an existing experiment.
 */
function updateExperiment() {
  var request = gapi.client.analytics.management.experiments.update(
    {
      'accountId': '123456',
      'webPropertyId': 'UA-123456-1',
      'profileId': '7654321',
      'experimentId': '122333444455555',
      '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. });
}