Skip to content

Add experiments examples#887

Open
sarahcaseybot wants to merge 2 commits into
mainfrom
experimentsExample
Open

Add experiments examples#887
sarahcaseybot wants to merge 2 commits into
mainfrom
experimentsExample

Conversation

@sarahcaseybot
Copy link
Copy Markdown
Contributor

No description provided.

@sarahcaseybot sarahcaseybot added the kokoro:run This label is required to run a kokoro presubmit if an external contributor sends a PR. label Jun 3, 2026
@kokoro-team kokoro-team removed the kokoro:run This label is required to run a kokoro presubmit if an external contributor sends a PR. label Jun 3, 2026
* the treatment arm automatically generates a draft campaign), modify the system-generated draft
* campaign, and schedule the experiment.
*
* <p>Note: This standard draft-based workflow does not apply to all experiment types (e.g.,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can fix this in the golden.

GoogleAdsServiceClient.SearchPagedResponse response = googleAdsServiceClient.search(request);

boolean experimentFound = false;
for (GoogleAdsRow row : response.iterateAll()) {
Copy link
Copy Markdown
Member

@jradcliff jradcliff Jun 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you get multiple rows back, given you're filtering by experiment_id? If not, it's a little confusing to have a for loop here. You could use something like https://guava.dev/releases/snapshot-jre/api/docs/com/google/common/collect/Iterables.html#getOnlyElement(java.lang.Iterable) instead.

}

// [START get_experiment_performance_1]
private void evaluateExperiment(GoogleAdsClient googleAdsClient, long customerId, GoogleAdsRow row) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add javadocs for each method

Comment on lines +29 to +32
* This example illustrates how to retrieve performance metrics for an experiment.
*
* <p>It shows how to query statistical significance metrics for the experiment,
* and how to execute actions such as promoting, ending, or graduating an experiment.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name and description of this example don't make it obvious that running this will potentially modify the state of the experiment.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. What about something like EvaluateAndUpdateExperiment or something like that?

For the description, do you mean that the first sentence should better capture what the example does, or you think the whole description is incomplete?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. What about something like EvaluateAndUpdateExperiment or something like that?

EvaluateAndUpdateExperiment SGTM. I just want it to be obvious to a user that running this is going to mutate things in their account.

For the description, do you mean that the first sentence should better capture what the example does

Exactly. It should mention the mutate piece. Javadoc uses the first sentence of the description in method summaries and IDEs use those summaries in tooltips, so it's important that the first sentence mentions the sample will modify entities.

}

private void graduateExperiment(GoogleAdsClient googleAdsClient, long customerId, String experimentResourceName) {
String budgetResourceName;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some line-level comments would be helpful since this method performs multiple steps

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can fix this in the golden. @sarahcaseybot I'll follow up with you on that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants