Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding segments.device doesn't work #43

Closed
sshemtov opened this issue Apr 28, 2022 · 16 comments
Closed

Adding segments.device doesn't work #43

sshemtov opened this issue Apr 28, 2022 · 16 comments
Assignees

Comments

@sshemtov
Copy link

sshemtov commented Apr 28, 2022

Hello,

Came across this error when trying to add segments.device to my query.

Error:
arguments imply differing number of rows: 10000, 5774

Might need to use cbind( ) instead of c( ) somewhere?

Thanks

@sshemtov
Copy link
Author

Same issue with segments.product_item_id

Most likely happens with more segments.

@jburkhardt
Copy link
Contributor

Could you please test and validate your query with the Google Ads Query Builder: https://developers.google.com/google-ads/api/fields/v10/query_validator
and provide your query here as code. Otherwise we cannot reproduce your error.
For instance this query with segments.device works just fine:

SELECT
  campaign.name, 
  campaign.status,
  segments.device,
  metrics.impressions,
  metrics.clicks,
  metrics.ctr,
  metrics.average_cpc,
  metrics.cost_micros
FROM campaign
WHERE segments.date DURING LAST_30_DAYS
AND metrics.impressions > 0
PARAMETERS include_drafts=true

@jburkhardt jburkhardt self-assigned this Apr 28, 2022
@sshemtov
Copy link
Author

Yes both are valid according to the link you provided

SELECT customer.descriptive_name, segments.product_item_id, metrics.impressions, metrics.clicks, metrics.cost_micros, metrics.conversions, metrics.conversions_value , metrics.search_absolute_top_impression_share, metrics.search_impression_share, metrics.search_click_share FROM shopping_performance_view WHERE segments.date BETWEEN '2022-03-22' AND '2022-04-27' AND metrics.impressions > 0 PARAMETERS include_drafts=true

SELECT segments.date, customer.descriptive_name, campaign.name, ad_group.name, segments.device , metrics.impressions, metrics.clicks, metrics.cost_micros, metrics.conversions_value , segments.product_custom_attribute1, segments.product_type_l1 FROM shopping_performance_view WHERE segments.date BETWEEN '2022-01-27' AND '2022-04-27' AND metrics.impressions > 0 PARAMETERS include_drafts=true

@sshemtov
Copy link
Author

If means anything I can get segments.device to work when the table is FROM ad_group

@jburkhardt
Copy link
Contributor

@sshemtov Thank you for the SQL queries. Both queries return data from my Google Ads account with shopping campaigns and there is no error.

@sshemtov
Copy link
Author

@sshemtov Thank you for the SQL queries. Both queries return data from my Google Ads account with shopping campaigns and there is no error.

0 clue what I'm doing wrong then. Works when I remove segments.device, then doesn't work when I add it in.

@jburkhardt
Copy link
Contributor

jburkhardt commented Apr 28, 2022

@sshemtov Can you run the query again with raw_data = T,:

test_query <- "SELECT customer.descriptive_name, segments.product_item_id, metrics.impressions, metrics.clicks, metrics.cost_micros, metrics.conversions, metrics.conversions_value , metrics.search_absolute_top_impression_share, metrics.search_impression_share, metrics.search_click_share FROM shopping_performance_view WHERE segments.date BETWEEN '2022-03-22' AND '2022-04-27'"

test_query_2 <- "SELECT segments.date, customer.descriptive_name, campaign.name, ad_group.name, segments.device , metrics.impressions, metrics.clicks, metrics.cost_micros, metrics.conversions_value , segments.product_custom_attribute1, segments.product_type_l1 FROM shopping_performance_view WHERE segments.date BETWEEN '2022-01-27' AND '2022-04-27'"

my_service = googleAdsSearch(
  aid = '*************',
  query = test_query,
  api_version = 'v10'
)

data <- query_google_ads(
  mcc_id = '***-***-****',
  google_auth = google_auth,
  service = my_service,
  raw_data = T,
  convert_micros = 1e6
)

And print the message if there is an error:

a <- fromJSON(rawToChar(data$content))
a

@sshemtov
Copy link
Author

@jburkhardt I was already doing raw_data = F

Here is error:
` data <- query_google_ads(
mcc_id = mccId, # Google Ads My Client Center ID
google_auth = google_auth,
service = query_service,
raw_data = F,
convert_micros = 1e+06
)

a <- fromJSON(rawToChar(data$content))
a `

@sshemtov
Copy link
Author

`> a <- fromJSON(rawToChar(data$content))
Error in rawToChar(data$content) : argument 'x' must be a raw vector

a
Error: object 'a' not found`

@jburkhardt
Copy link
Contributor

Updated above: raw_data = T

@sshemtov
Copy link
Author

raw = T gets me this error now

Error in df[, grepl("metrics.", names(df))] :
incorrect number of dimensions

@jburkhardt
Copy link
Contributor

This code works just fine for me with both of your queries:

test_query <- "SELECT customer.descriptive_name, segments.product_item_id, metrics.impressions, metrics.clicks, metrics.cost_micros, metrics.conversions, metrics.conversions_value , metrics.search_absolute_top_impression_share, metrics.search_impression_share, metrics.search_click_share FROM shopping_performance_view WHERE segments.date BETWEEN '2022-03-22' AND '2022-04-27'"
test_query_2 <- "SELECT segments.date, customer.descriptive_name, campaign.name, ad_group.name, segments.device , metrics.impressions, metrics.clicks, metrics.cost_micros, metrics.conversions_value , segments.product_custom_attribute1, segments.product_type_l1 FROM shopping_performance_view WHERE segments.date BETWEEN '2022-01-27' AND '2022-04-27'"

my_service = googleAdsSearch(
  aid = '**********',
  query = test_query_2,
  api_version = 'v10'
)

data <- query_google_ads(
  mcc_id = '***-***-****',
  google_auth = google_auth,
  service = my_service,
  raw_data = F,
  convert_micros = 1e6
)

data

As I cannot reproduce the issue it is difficult to support!

@jburkhardt
Copy link
Contributor

@sshemtov Please make sure you use the latest version of r4googlads 0.1.1 remotes::install_github("banboo-data/r4googleads")

@sshemtov
Copy link
Author

@jburkhardt just tried remotes::install_github("banboo-data/r4googleads"), still didn't work

@sshemtov
Copy link
Author

full code with X's for account info

`remotes::install_github("banboo-data/r4googleads")
library(r4googleads)

google_auth <- authenticate()

test_query <- "SELECT customer.descriptive_name, segments.product_item_id, metrics.impressions, metrics.clicks, metrics.cost_micros, metrics.conversions, metrics.conversions_value , metrics.search_absolute_top_impression_share, metrics.search_impression_share, metrics.search_click_share FROM shopping_performance_view WHERE segments.date BETWEEN '2022-03-22' AND '2022-04-27'"
test_query_2 <- "SELECT segments.date, customer.descriptive_name, campaign.name, ad_group.name, segments.device , metrics.impressions, metrics.clicks, metrics.cost_micros, metrics.conversions_value , segments.product_custom_attribute1, segments.product_type_l1 FROM shopping_performance_view WHERE segments.date BETWEEN '2022-01-27' AND '2022-04-27'"

my_service = googleAdsSearch(
aid = "xxx-xxx-xxxx",
query = test_query,
api_version = 'v10'
)

data <- query_google_ads(
mcc_id = "xxx-xx-xxxx",
google_auth = google_auth,
service = my_service,
raw_data = F,
convert_micros = 1e6
)
data`

@sshemtov
Copy link
Author

Error in data.frame(..., check.names = FALSE) :
arguments imply differing number of rows: 10000, 461

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants