Event counting through the Google Analytics API

Can the Google Analytics API be used to count the number of times a particular event has been tracked?

In particular, is it possible to calculate this number in such a way that each unique visitor to this event is counted only once (subsequent events for each unique visitor are not included in the total value).

I'm going to access the API through PHP, for what it's worth it.

+5
source share
2 answers

Yes.

You would specify a dimension ga:eventCategoryor ga:eventActioneither ga:eventLabel(or two or all of them) depending on what level of event you want to count on.

ga:uniqueEvents, . ( .) ga:totalEvents.

, . , Foo :

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

Google Analytics.

+12

, ... java- google analytics query explorer

/ * JAVA CODE */

DataQuery query = new DataQuery(new URL(
                "https://www.googleapis.com/analytics/v2.4/data"));

query.setStartDate("2013-08-25");

query.setEndDate("2013-09-24");

//query.setDimensions("ga:pageTitle,ga:pagePath");

query.setDimensions("ga:pageTitle,ga:eventCategory");

//query.setFilters("ga:pagePath=~forgot.action");

query.setFilters("ga:eventCategory==/*Your event as per Google Analytics*/");

//query.setMetrics("ga:pageviews");

query.setMetrics("ga:uniqueEvents");

//query.setSort("-ga:pageviews");

//query.setSort("-ga:visitors");

query.setMaxResults(10);

query.setIds(/*YOUR TABLE ID*/);

, .

0

All Articles