问题
In Google Analytics I have set up set a custom dimension that contains a string of tags (ga:dimension1
).
Data Example: "tag1,tag2,tag3"
. I also use events.
I use Query Explorer to test some custom reports. For tag2
it is working like this:
- metrics:
ga:totalEvents
- dimensions:
ga:dimension1
- sort:
ga:totalEvents
- filters:
ga:dimension1=~(tag2)
I receive results like this:
Custom Dimension 1 | Total Events
tag2 | 2
tag1,tag2 | 1
tag3,tag1,tag2 | 4
Is there a solution to count these results in a GA query and to receive something like:
tag2 | 7
So I need a single number as result - the count of column Total Events in these rows.
回答1:
The best you are going to be able to do is to either remove the dimension and just request ga:TotalEvents.
- metrics:
ga:totalEvents
- sort:
ga:totalEvents
- filters:
ga:dimension1=~(tag2)
This will return
7
Why
The reason its not working like you want it to is you are requesting a column in the database ga:dimesion1 and ga:TotalEvents. The system is going to return unique values for each of them.
There are apparently rows for
tag2
tag1,tag2
tag3,tag1,tag2
There could just as easily be tag2,tag1
which is different from
tag1,tag2
I hope this makes sense
来源:https://stackoverflow.com/questions/30776388/ga-query-to-return-unique-count-number