Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First, review the <a href="https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/experiments/insert" rel="nofollow">API Reference for the Experiment INSERT method</a>.</p> <p>It requires that you make a POST request, and in the request body you need to supply an Experiment resource. In this case the required property/fields are name, status, and variation names. You also need to set objectiveMetric because as per the reference, this field is required if status is "RUNNING" and servingFramework is one of "REDIRECT" or "API". </p> <p>If you're using the JavaScript client then you'll need to use gapi.client.request to execute this method. You can't do it the way you've described since that will make a GET request, and you haven't supplied a request body. You need to make a POST request with a request body. Take a look at <a href="https://developers.google.com/api-client-library/javascript/dev/dev_jscript#Option2usegapiclientrequest" rel="nofollow">Using gapi.client.request to make REST requests</a>.</p> <p>So it would look something like:</p> <pre><code>var requestBody = { 'name': 'Testing', 'status': 'RUNNING', 'objectiveMetric': 'ga:timeOnSite', 'variations': [ {'name': 'VER 1', 'status': 'ACTIVE', 'url': 'http://abs.com/1'}, {'name': 'VER 2', 'status': 'ACTIVE', 'url': 'http://abs.com/2'} ], }; var request = gapi.client.request({ 'path': '/analytics/v3/management/accounts/YOUR_ACCOUNT_ID/webproperties/YOUR_WEBPROPERTY_ID/profiles/YOUR_PROFILE_ID/experiments', 'method': 'POST', 'body': JSON.stringify(requestBody)}); request.execute(handleAccounts); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload