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>
</soapenv:Header>
<soapenv:Body>
<selector>
<ns7:includeSubUrls>true</ns7:includeSubUrls>
</searchParameters>
<ns8:locations>
</ns8:locations>
</searchParameters>
<ideaType>KEYWORD</ideaType>
<requestType>IDEAS</requestType>
<requestedAttributeTypes>KEYWORD_TEXT</requestedAttributeTypes>
<paging>
</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: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>
<ns2:message>[TargetingIdeaError.INVALID_SEARCH_PARAMETERS @ selector.searchParameters[0].includeSubUrls]</ns2:message>
<ns2:ApplicationException.Type>ApiException</ns2:ApplicationException.Type>
<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