This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_draft(): | |
adwords_client = connect_to_adwords_api() | |
draft_service = adwords_client.GetService('DraftService', version='v201809') | |
draft = { | |
'baseCampaignId': original_campaign_id, | |
'draftName': {draft_name} | |
} | |
draft_operation = {'operator': 'ADD', 'operand': draft} | |
draft = draft_service.mutate([draft_operation])['value'][0] | |
draft_campaign_id = draft['draftCampaignId'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_and_assign_budget(): | |
adwords_client = connect_to_adwords_api() | |
# This bit here creates the budget | |
budget_service = adwords_client.GetService('BudgetService', version='v201809') | |
budget = { | |
'name': {an appropriate name}, # Doesn't need to be unique. Budget Id is what matters for uniqueness | |
'amount': { | |
'microAmount': int(round({budget_amount} * 1000000)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from googleads import adwords | |
from googleads import oauth2 | |
def connect_to_adwords_api(): | |
customer_id = 'xxx-xxx-xxxx' # This is client customer ID you see in the google ads UI | |
oauth2_client = oauth2.GoogleRefreshTokenClient( | |
client_id={GOOGLE_CLIENT_ID}, | |
client_secret={GOOGLE_CLIENT_SECRET}, | |
refresh_token={GOOGLE_REFRESH_TOKEN} |
NewerOlder