Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Sandy4321/901c835e66b058c38675cb1615e98d73 to your computer and use it in GitHub Desktop.
Save Sandy4321/901c835e66b058c38675cb1615e98d73 to your computer and use it in GitHub Desktop.
def create_experiment(experiment_name, base_campaign_id, draft_id, split_percent=50, split_type='COOKIE'):
adwords_client = connect_to_adwords_api()
trial_service = adwords_client.GetService('TrialService', version='v201809')
trial = {
'draftId': draft_id,
'baseCampaignId': base_campaign_id,
'name': experiment_name,
'trafficSplitPercent': split_percent,
'trafficSplitType': split_type
}
trial_operation = {'operator': 'ADD', 'operand': trial}
trial_id = trial_service.mutate([trial_operation])['value'][0]['id']
return trial_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment