问题
I am using custom variables to track order ids. In order to aggregate analytics data into out data warehouse, I want to select a number of metrics with the custom variable as a dimension. However, if I do so, I will not get the entries where the variable is not set (E.g. sessions that didn't result in a sale). I need to get these as well.
Can I write a filter or segment that selects only the entries that doesn't have a particular custom variable? I have tried:
segment=dynamic::ga:customVarValue1==
But that doesn't seem to work (It gives no results back).
Basically I'm looking for the equivalent to where ga:customVarValue1 is null
in sql.
回答1:
In short, it's not possible to get the nullset data, as explained by a Google rep:
For some dimensions, GA uses the default value of (not set). Custom Variable do not have a default value, so if a hit does not have a custom variable associated with it, all the other dimensions in the query are not added to the reports.
The original answer is a little confusing, but when you read between the lines it suggests that they throw out these "empty" values when they run their aggregates.
The "correct" approach, as he explains, is to set a default value for any row you want reported:
If you need to see the (not set) value, you could try sending a default value for custom variables.
For example if you use visitor level custom vars to track member vs non-member, you should always set non-member as a default for everybody; then modify to member once they register.
Details are here: http://groups.google.com/group/google-analytics-data-export-api/browse_thread/thread/cd078ddb26ca18d5?pli=1
回答2:
I've just had some success solving this by using a Regex to capture users or sessions where the custom dimension has no value. In my case I want to separate logged in and logged out users.
The Regex .+
will capture any non-empty value, so can be used to get the job done.
The filters for my Returning users segment is matches regex: .+
like this:
For the Customer prospects I used: does not match regex: .+
like this:
It's early days, but this appears to be working:
来源:https://stackoverflow.com/questions/7374550/how-can-i-get-results-for-a-dimension-custom-variables-where-the-value-is-not