Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Analytics API error "Selected dimensions and metrics cannot be queried together."

I have to retrieve as many different metrics from my GA ecommerce as I can all at once. I'm using google api ruby client for that. And keep getting an error:

"message"=>"Selected dimensions and metrics cannot be queried together." 

for example, for this request:

result = client.execute(api_method: api_method.data.ga.get, parameters: {
    'ids'        => 'ga:95561781',
    'start-date' => Date.new(2006,1,1).to_s,
    'end-date'   => Date.today.to_s,
    'dimensions' => 'ga:source,ga:medium,ga:country,ga:transactionId,ga:affiliation,ga:productSku,ga:productName',
    'metrics'    => 'ga:sessions,ga:transactionRevenue,ga:transactions,ga:uniquePurchases,ga:totalValue,ga:transactionTax'
})

How do I know what request metrics and dimensions I can combine and what not? And how can I retrieve as many data as I can?

like image 968
Incerteza Avatar asked Dec 14 '22 16:12

Incerteza


1 Answers

Not all dimensions and metrics can be queried together.

Selected dimensions and metrics cannot be queried together

Means that your request contains dimensions or metrics that can not be mixed.

You may use the Dimensions and Metrics developer reference to see which metrics and dimensions can be used together in your query

like image 75
maggieto Avatar answered Jan 09 '23 10:01

maggieto