Search code examples
google-analyticsgoogle-analytics-apigoogle-api-client

Getting dimension data from Google analytics even when the data for that dimension is not available


I am using the Google Analytics reporting tool in PHP.

I am having trouble when i am Querying the data when the Dimension data is not available.

For example : These are the dimension ga:date,ga:countryIsoCode,ga:eventCategory,ga:eventAction,ga:eventLabel which i have.

These are the metrics ga:totalEvents which i have.

But the problem is that for some data ga:eventLabel is present and for some ga:eventLabel is not Present.

When i query using the dimension and metrics in the result set data does not include the data which does not have ga:eventLabel.

How can i get the data even when the ga:eventLabel is missing?


Solution

  • This is how GA reporting works. Empty dimensions will almost always filter away the other dimensions. (few exceptions where GA uses (not set)) You either need to always add a value to the ga:eventLabel upstream while tracking or do the hard query work. 1. ga:eventCategory 2. ga:eventCategory,ga:eventAction 3. ga:eventCategory,ga:eventAction,ga:eventLabel Then you - intelligently - stitch the dataset together. You need to make sure you don't use result from 1 that is drill down in 2 etc.