Home > Net >  google ads api doesn't return rows with null columns
google ads api doesn't return rows with null columns

Time:04-22

Migrating from AdWords to GoogleAds api.

Querying search_term_view:

val googleAdsClient: GoogleAdsClient = GoogleAdsClient.newBuilder()
  .setCredentials(credential)
  .setDeveloperToken(developerToken)
  .setLoginCustomerId(loginCustomerId.toLong)
  .build()
   
val svc = googleAdsClient.getLatestVersion.createGoogleAdsServiceClient()

val query = s"""
  SELECT 
    segments.keyword.info.text
    ,search_term_view.search_term
    ,segments.date
  FROM search_term_view
  WHERE segments.date BETWEEN '2022-01-01' AND '2022-01-01'
"""

svc.search(customerId, query).iteratePages().asScala.foreach { page =>
  page.iterateAll().asScala.foreach { row =>
    //row processing
  }
}

The issue is that svc.search() skips rows, if one of columns is null. So getting results like

text1,term1
text2,term2

While same request to Adwords api returns results like

text1,term1
text2,term2
--,term3

Haven't found anything about nulls ignoring in docs.

Using latest google ads v10 lib: "com.google.api-ads" % "google-ads" % "17.0.1"

CodePudding user response:

Received response from google team:

"Using segments fields in your query may result in fewer records being returned. This behavior is further explained in this section of our segmentation guide. If no values can be associated to the segments field that is included in the SELECT clause, then no records will also be returned for it.

In addition, zero metrics records may also not be returned when segments fields are used as per this other guide."

  • Related