We’ve released the ConstantDataService as a new service with v201109. This blog post will talk about what it is used for as well as suggest some best practices.
The ConstantDataService currently has two web service methods available: getCarrierCriterion and getLanguageCriterion. These methods return Carrier and Language criteria respectively. These criteria can be used with the CampaignCriterion to get more fine-grained control of the targeting of your campaigns. This functionality replaces the CampaignTargetService’s LanguageTarget and MobileCarrierTarget.
Previously, we published lists of these targets/criteria in static files on code.google.com as the sole way to get a list of possible options. With the ConstantDataService, we are now exposing these values programmatically via the AdWords API. As a result, your application can now dynamically obtain a list of options for these criteria. Let’s see how to get a list of Carriers in Python.
# Initialize client object.
client = AdWordsClient(path=os.path.join('..', '..', '..', '..'))
# Initialize appropriate service.
constant_data_service = client.GetConstantDataService(
'https://adwords-sandbox.google.com', 'v201109')
# Get all carriers.
carriers = constant_data_service.GetCarrierCriterion()
# Display results.
for carrier in carriers:
print ('Carrier with name \'%s\', ID \'%s\', and country code \'%s\''
' was found.' % (carrier['name'], carrier['id'], carrier['countryCode']))
Output from this script would look like this:
Carrier with name 'NTT DoCoMo', ID '70000', and country code 'JP' was found.
Carrier with name 'KDDI/au', ID '70001', and country code 'JP' was found.
Carrier with name 'Vodafone', ID '70002', and country code 'JP' was found.
Carrier with name 'EMOBILE', ID '70003', and country code 'JP' was found.
Carrier with name 'WILLCOM', ID '70004', and country code 'JP' was found.
Carrier with name 'T-Mobile', ID '70030', and country code 'DE' was found.
[snip]
The dataset that the ConstantDataService exposes can now be easily updated while allowing your applications to dynamically stay up-to-date. We do not expect the dataset to change often and we expect most changes to be additive in nature. As a result, we strongly encourage caching this information rather than looking it up on demand. For example, in Python, you could store this information in a pickle or a database and reuse it as necessary.
We hope you have found this post discussing the ConstantDataService and its use in obtaining Carrier and Language criteria to be informative. If you have any questions about this service or how to use it, please post on the forum or try to attend our Google+ Hangouts with members of the AdWords API Developer Relations Team.
The ConstantDataService currently has two web service methods available: getCarrierCriterion and getLanguageCriterion. These methods return Carrier and Language criteria respectively. These criteria can be used with the CampaignCriterion to get more fine-grained control of the targeting of your campaigns. This functionality replaces the CampaignTargetService’s LanguageTarget and MobileCarrierTarget.
Previously, we published lists of these targets/criteria in static files on code.google.com as the sole way to get a list of possible options. With the ConstantDataService, we are now exposing these values programmatically via the AdWords API. As a result, your application can now dynamically obtain a list of options for these criteria. Let’s see how to get a list of Carriers in Python.
# Initialize client object.
client = AdWordsClient(path=os.path.join('..', '..', '..', '..'))
# Initialize appropriate service.
constant_data_service = client.GetConstantDataService(
'https://adwords-sandbox.google.com', 'v201109')
# Get all carriers.
carriers = constant_data_service.GetCarrierCriterion()
# Display results.
for carrier in carriers:
print ('Carrier with name \'%s\', ID \'%s\', and country code \'%s\''
' was found.' % (carrier['name'], carrier['id'], carrier['countryCode']))
Output from this script would look like this:
Carrier with name 'NTT DoCoMo', ID '70000', and country code 'JP' was found.
Carrier with name 'KDDI/au', ID '70001', and country code 'JP' was found.
Carrier with name 'Vodafone', ID '70002', and country code 'JP' was found.
Carrier with name 'EMOBILE', ID '70003', and country code 'JP' was found.
Carrier with name 'WILLCOM', ID '70004', and country code 'JP' was found.
Carrier with name 'T-Mobile', ID '70030', and country code 'DE' was found.
[snip]
The dataset that the ConstantDataService exposes can now be easily updated while allowing your applications to dynamically stay up-to-date. We do not expect the dataset to change often and we expect most changes to be additive in nature. As a result, we strongly encourage caching this information rather than looking it up on demand. For example, in Python, you could store this information in a pickle or a database and reuse it as necessary.
We hope you have found this post discussing the ConstantDataService and its use in obtaining Carrier and Language criteria to be informative. If you have any questions about this service or how to use it, please post on the forum or try to attend our Google+ Hangouts with members of the AdWords API Developer Relations Team.