TargetingIdeaService: "Use the entire site" option

84 views
Skip to first unread message

Thanawat Muangsawang

unread,
Jul 20, 2020, 5:30:50 AM7/20/20
to AdWords API and Google Ads API Forum
Hello,

Now I am using the TargetingIdeaService to get some keyword ideas of websites.

And I noticed that the keyword ideas returned from the AdWords API look different from the keyword ideas returned from Keyword Planner, however, when I chose the "Use only this page" option, it turned out that the keyword ideas returned from Keyword Planner look like the keyword ideas from the API.

*Note: the entered domain name is just an example. 


If I understand correctly, the API chooses the "Use only this page" option by default.

How can I change the option to "Use the entire site" from the API?

I tried searching in the other similar conversations, it seems like we can put the "includeSubUrls" field to true to make the results returned as the "Use the entire site" option. Is that correct?

However, when I tried changing this option to true, I got INVALID_SEARCH_PARAMETERS error:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <soapenv:Header>
        <ns1:RequestHeader xmlns:ns1="https://adwords.google.com/api/adwords/o/v201809" soapenv:mustUnderstand="0">
            <ns2:clientCustomerId xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201809">XXXXXXX</ns2:clientCustomerId>
            <ns3:developerToken xmlns:ns3="https://adwords.google.com/api/adwords/cm/v201809">REDACTED</ns3:developerToken>
            <ns4:userAgent xmlns:ns4="https://adwords.google.com/api/adwords/cm/v201809">unknown (AwApi-Java, AdWords-Axis/4.10.0, Common-Java/4.10.0, Axis/1.4, Java/1.8.0_191, maven)</ns4:userAgent>
            <ns5:validateOnly xmlns:ns5="https://adwords.google.com/api/adwords/cm/v201809">false</ns5:validateOnly>
            <ns6:partialFailure xmlns:ns6="https://adwords.google.com/api/adwords/cm/v201809">false</ns6:partialFailure>
        </ns1:RequestHeader>
    </soapenv:Header>
    <soapenv:Body>
            <selector>
                <searchParameters xmlns:ns7="https://adwords.google.com/api/adwords/o/v201809" xsi:type="ns7:RelatedToUrlSearchParameter">
                    <ns7:urls>www.example.com</ns7:urls>
                    <ns7:includeSubUrls>true</ns7:includeSubUrls>
                </searchParameters>
                <searchParameters xmlns:ns8="https://adwords.google.com/api/adwords/o/v201809" xsi:type="ns8:LocationSearchParameter">
                    <ns8:locations>
                        <ns9:id xmlns:ns9="https://adwords.google.com/api/adwords/cm/v201809">2250</ns9:id>
                    </ns8:locations>
                </searchParameters>
                <ideaType>KEYWORD</ideaType>
                <requestType>IDEAS</requestType>
                <requestedAttributeTypes>KEYWORD_TEXT</requestedAttributeTypes>
                <paging>
                    <ns10:startIndex xmlns:ns10="https://adwords.google.com/api/adwords/cm/v201809">0</ns10:startIndex>
                    <ns11:numberResults xmlns:ns11="https://adwords.google.com/api/adwords/cm/v201809">10</ns11:numberResults>
                </paging>
            </selector>
        </get>
    </soapenv:Body>
</soapenv:Envelope>

2020-07-20 16:17:32.233  INFO 22896 --- [           main] c.g.a.a.a.l.c.A.soapXmlLogger            : SOAP response:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Header>
            <ns2:requestId>XXXXXX</ns2:requestId>
            <ns2:serviceName>ExperimentDiversionService</ns2:serviceName>
            <ns2:methodName>get</ns2:methodName>
            <ns2:operations>1</ns2:operations>
            <ns2:responseTime>267</ns2:responseTime>
        </ResponseHeader>
    </soap:Header>
    <soap:Body>
        <soap:Fault>
            <faultcode>soap:Server</faultcode>
            <faultstring>[TargetingIdeaError.INVALID_SEARCH_PARAMETERS @ selector.searchParameters[0].includeSubUrls]</faultstring>
            <detail>
                <ApiExceptionFault xmlns="https://adwords.google.com/api/adwords/o/v201809" xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201809">
                    <ns2:message>[TargetingIdeaError.INVALID_SEARCH_PARAMETERS @ selector.searchParameters[0].includeSubUrls]</ns2:message>
                    <ns2:ApplicationException.Type>ApiException</ns2:ApplicationException.Type>
                    <ns2:errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="TargetingIdeaError">
                        <ns2:fieldPath>selector.searchParameters[0].includeSubUrls</ns2:fieldPath>
                        <ns2:fieldPathElements>
                            <ns2:field>selector</ns2:field>
                        </ns2:fieldPathElements>
                        <ns2:fieldPathElements>
                            <ns2:field>searchParameters</ns2:field>
                            <ns2:index>0</ns2:index>
                        </ns2:fieldPathElements>
                        <ns2:fieldPathElements>
                            <ns2:field>includeSubUrls</ns2:field>
                        </ns2:fieldPathElements>
                        <ns2:trigger/>
                        <ns2:errorString>TargetingIdeaError.INVALID_SEARCH_PARAMETERS</ns2:errorString>
                        <ns2:ApiError.Type>TargetingIdeaError</ns2:ApiError.Type>
                        <reason>INVALID_SEARCH_PARAMETERS</reason>
                    </ns2:errors>
                </ApiExceptionFault>
            </detail>
        </soap:Fault>
    </soap:Body>
</soap:Envelope>

Here is the code I use (Java): 
String url = "XXXXXXXXXX";
            long locationId = 2250;
            int limit = 10;

            Credential oAuth2Credential = new OfflineCredentials.Builder().forApi(OfflineCredentials.Api.ADWORDS).fromFile().build().generateCredential();
            AdWordsSession session = new AdWordsSession.Builder().fromFile().withOAuth2Credential(oAuth2Credential).build();

            // Get the TargetingIdeaService.
            TargetingIdeaServiceInterface targetingIdeaService = AdWordsServices.getInstance().get(session, TargetingIdeaServiceInterface.class);

            // Create selector.
            TargetingIdeaSelector selector = new TargetingIdeaSelector();

            selector.setRequestType(RequestType.IDEAS);
            selector.setIdeaType(IdeaType.KEYWORD);

            selector.setRequestedAttributeTypes(new AttributeType[]{
                AttributeType.KEYWORD_TEXT
            });

            // Set selector paging (required for targeting idea service).
            Paging paging = new Paging();
            paging.setStartIndex(0);
            paging.setNumberResults(limit);
            selector.setPaging(paging);

            List<SearchParameter> searchParameters = new ArrayList<>();

            // Create related to query search parameter.
            RelatedToUrlSearchParameter relatedToUrlSearchParameter = new RelatedToUrlSearchParameter();
            relatedToUrlSearchParameter.setUrls(new String[]{url});
            relatedToUrlSearchParameter.setIncludeSubUrls(true);

            searchParameters.add(relatedToUrlSearchParameter);

            LocationSearchParameter locationParameter = new LocationSearchParameter();

            Location location = new Location();
            location.setId(locationId);
            locationParameter.setLocations(new Location[]{location});

            searchParameters.add(locationParameter);

            selector.setSearchParameters(searchParameters.toArray(new SearchParameter[searchParameters.size()]));

            TargetingIdeaPage page = targetingIdeaService.get(selector);

            if (page != null && page.getEntries() != null) {
                for (TargetingIdea targetingIdea : page.getEntries()) {
                    Map<AttributeType, Attribute> data = Maps.toMap(targetingIdea.getData());
                    StringAttribute keyword = (StringAttribute) data.get(AttributeType.KEYWORD_TEXT);
                    System.out.println(keyword.getValue());
                }
            }

If I only change the parameter in the red line to false, there is no error occurred, but the results are not what I expected, could you please let me know what did I miss?

I am not sure which information I can provide here, if you need more information that I put in "XXXXXXXX", please let me know I will send you privately.

Thank you.
Best regards,
Thanawat




Google Ads API Forum Advisor Prod

unread,
Jul 20, 2020, 2:30:42 PM7/20/20
to thanawat.m...@gmail.com, adwor...@googlegroups.com
Hi Thanawat,

Thank you for reaching out. Can you please share the un-masked logs via Reply privately to author so I can further investigate the issue?

Regards,
Mitchell
Google Ads API Team

ref:_00D1U1174p._5004Q22XT31:ref
Reply all
Reply to author
Forward
0 new messages