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:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
    <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>
        <get xmlns="https://adwords.google.com/api/adwords/o/v201809";>
            <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>
        <ResponseHeader 
xmlns="https://adwords.google.com/api/adwords/o/v201809"; 
xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201809";>
            <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




-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/0f903445-af86-40a8-8223-5ba63611caabn%40googlegroups.com.

Reply via email to