Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Counting events through the Google Analytics APIs

Is it possible to use the Google Analytics APIs get a count of the number of times a certain event has been tracked?

More specifically, can this number be counted in such a way that each unique visitor who hits this event is counted only once (subsequent events for each unique visitor are not included in the total).

I am intending to access the API through PHP, for what it's worth.

like image 708
Simon Cave Avatar asked Nov 16 '11 02:11

Simon Cave


1 Answers

Yes.

You'd set your dimension to be ga:eventCategory, or ga:eventAction or ga:eventLabel (or two or all of them), depending on what level of the event you want to count.

You'd set your metric to be ga:uniqueEvents, which only counts the event once per visit. (You don't have the ability to make it unique according to visitor.) For total events, you'd set it to ga:totalEvents.

And you'd set your filter to filter down to which events you'd like to account for. For example, for events of category Foo and action Bar:

ga:eventCategory==Foo;ga:eventAction==Bar

You can test it out in the Google Analytics Data Feed Query Explorer.

like image 89
Yahel Avatar answered Oct 19 '22 04:10

Yahel