Why: Adwords API doesn't merge keywords that are close variants to 1 keywords like Keyword Planner does.

120 views
Skip to first unread message

Doan Minh Tien

unread,
Oct 1, 2018, 7:55:14 AM10/1/18
to AdWords API and Google Ads API Forum
This is my list of keywords when I use the API to retrieve Search Volume:
  • best san francisco walking tour
  • best walking tour of san francisco
  • best walking tours in san francisco
  • francisbest walking tours of san
Results: (I printed them out):
{'KEYWORD_TEXT': 'best san francisco walking tour', 'SEARCH_VOLUME': 140}
{'KEYWORD_TEXT': 'best walking tour of san francisco', 'SEARCH_VOLUME': 140}
{'KEYWORD_TEXT': 'best walking tours in san francisco', 'SEARCH_VOLUME': 140}
{'KEYWORD_TEXT': 'best walking tours of san francisco', 'SEARCH_VOLUME': 140}

======

I input those keyword to Keyword Planner as well, and this is the result

google adwords keyword planner.png

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;


Sreelakshmi Sasidharan (AdWords API Team)

unread,
Oct 1, 2018, 1:59:43 PM10/1/18
to AdWords API and Google Ads API Forum
Hello, 

Performing a similar test at my end, I see that the AdWords API is returning 4 entries each which has 140 as SEARCH_VOLUME for the first 3 and no results for the last one. Which is matching with the keyword planner in the UI. As you observed, keyword planner is combining the close variants together and returning one row with the status. You might have observed the message "Some keywords you entered and their close variants have been grouped into one row" in the keyword planner. I feel, you may need to change the logic of how you are calculating the search volume of 4 keywords in one ad group. My suggestion is to post the questions about deriving the search volume in an ad group in the advertisers community forum. The product experts there should be able to guide you better. 

Thanks,
Sreelakshmi, AdWords API Team
Reply all
Reply to author
Forward
0 new messages