Part 2 - Script Overview

In this part we'll break down parts of the original Create Complete Campaign AdWords API Only script and highlight some key components before we start making changes.

This script imports the AdWords API client library and uses it to initialize an AdWords client.

2.0.0: Importing the AdWords API Client Library
# This line imports the AdWords client library
from googleads import adwords

When calling LoadFromStorage the OAuth2 credentials are loaded from a configuration file that is stored on the local machine.

2.0.1: Initializing an AdWords API Client
# This line initializes the AdWords client
adwords_client = adwords.AdWordsClient.LoadFromStorage()

This script creates a number of entities, one-at-a-time, and uses the ID of each created entity as an input to create the next one. For example, the first step is to create a budget, whose ID is then used to create a campaign in the next step.

2.0.2: Flow of Method Calls in Original Script (AdWords API)
# Create a Budget and save its ID
budget_id = _create_campaign_budget(adwords_client)
# Use the Budget's ID to create a Campaign
campaign_id = _create_campaign(adwords_client, budget_id)
# Use the Campaign's ID to create and AdGroup
ad_group_id = _create_ad_group(adwords_client, campaign_id)
# Use the AdGroup's ID to create Ads
_create_text_ads(adwords_client, ad_group_id)
# Use the AdGroup's ID to create keyword Criteria
_create_keywords(adwords_client, ad_group_id, KEYWORDS_TO_ADD)