
You can see that there is only 1 keyword here (with 140 SV)
====
This is a problem because if I group all of those 4 keywords to 1 group, the SV for this group would be (140 * 4 = 560) which doesn't match which Keyword Planner (140)
Note: My understanding is when KW Planner merges all of those keywords to 1 keyword, then sum SV for all of those 4 keywords would be 140.
Code I'm using to get SV:
def get_keyword_sv(keywords, client=None, ad_group_id=None): print("start get sv"); if client is None: client = adwords.AdWordsClient.LoadFromStorage() # Initialize appropriate service. targeting_idea_service = client.GetService( 'TargetingIdeaService', version='v201809')
# Construct selector object and retrieve related keywords. selector = { 'ideaType': 'KEYWORD', 'requestType': 'STATS' }
selector['requestedAttributeTypes'] = [ 'KEYWORD_TEXT', 'SEARCH_VOLUME']
offset = 0 selector['paging'] = { 'startIndex': str(offset), 'numberResults': str(PAGE_SIZE) }
selector['searchParameters'] = [{ 'xsi_type': 'RelatedToQuerySearchParameter', 'queries': keywords }]
# Language setting (optional). selector['searchParameters'].append({ # The ID can be found in the documentation: 'xsi_type': 'LanguageSearchParameter', 'languages': [{'id': '1000'}] })
# Network search parameter (optional) selector['searchParameters'].append({ 'xsi_type': 'NetworkSearchParameter', 'networkSetting': { 'targetGoogleSearch': True, 'targetSearchNetwork': False, 'targetContentNetwork': False, 'targetPartnerSearchNetwork': False } })
# Use an existing ad group to generate ideas (optional) if ad_group_id is not None: selector['searchParameters'].append({ 'xsi_type': 'SeedAdGroupIdSearchParameter', 'adGroupId': ad_group_id })
keyword_search_volumes = []
more_pages = True while more_pages: page = targeting_idea_service.get(selector)
# Display results. if 'entries' in page: for result in page['entries']: attributes = {} for attribute in result['data']: attributes[attribute['key']] = getattr( attribute['value'], 'value', '0')
print(attributes) keyword_search_volumes = keyword_search_volumes + [[attributes['KEYWORD_TEXT'], attributes['SEARCH_VOLUME']]]; # print(('Keyword with "%s" text and average monthly search volume ' # '"%s" was found with Products and Services categories: %s.' # % (attributes['KEYWORD_TEXT'], # attributes['SEARCH_VOLUME'], # attributes['CATEGORY_PRODUCTS_AND_SERVICES']))) else:
#please ignore this else print('No related keywords were found.') offset += PAGE_SIZE selector['paging']['startIndex'] = str(offset) more_pages = offset < int(page['totalNumEntries'])
print("done get SV");
return keyword_search_volumes;