Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export Google Analytics data (log of events)

I have some applications and a website that trigger Google Analytics events. I would like to export google analytics events to my datawarehouse in order to have better insights and analytics.

For this question, you can use the language you want (python, ruby, java, etc.).

I'm not an expert in Google Analytics, I don't know if it's feasible, but can I get a log of all events that were triggered ? It would look like that :

   event_id    |   user_id    |   date     |      foo
   ----------------------------------------------------
        210    |    1245076   | 07-08-2015 |   bla
        211    |      124     | 07-08-2015 |   bla2
        214    |    1245081   | 07-08-2015 |   bla3
        215    |     48789    | 07-09-2015 |   last line

If not, could I at least get it by session ? Like this :

   session_id  |   user_id    |   date     |      foo
   ----------------------------------------------------
        210    |    1245076   | 07-08-2015 |   bla
        211    |      124     | 07-08-2015 |   bla2
        214    |    1245081   | 07-08-2015 |   bla3
        215    |     48789    | 07-09-2015 |   last line

If it is not possible, what are the closest things to a log of event I can get ? (I know "close to" is vague ...) I mean, google analytics tends to aggregate things, and I would prefer not to have aggregates ...

That's the first part, then the second part is from the result of a query insert it into the datawarehouse, but it is not the problematic part.

Note (EDIT) : in this question, the "quota" aspect (Google Analytics API limits the number of daily requests) can be ommited in a first time. By that I mean, is it possible to get data in the format I want, if yes then we can ask ourselves how to do that efficiently given the limitations

Thanks in advance !

like image 516
Pholochtairze Avatar asked Oct 19 '22 07:10

Pholochtairze


1 Answers

Google Analytics doesn't provide you with any data that contains id

Its a part of Google Analytics Premium, you get a full table of all the info you want about fullVisitorId and visitId (sessionId)

Big Query Export Schema has a detailed info about the data you can have


There exists a way to do this without going for the premium service of Google Analytics

Solution : If you don't want the data to get aggregated add dimensions of your choice to segment the data. In this case user_id and event_id

Approach one

In Google Analytics Event Report is something you can use,

Event Category : send the user_id, generated by your JS code

Event Action : send the event_id, again generated by your JS code

Event Label : foo

Date this is a default dimension that is available in Google Analytics

Approach two

Custom Dimesnion : send the user_id, generated by your JS code

Event Category : send the event_id, generated by your JS code

Event Action : foo

Date this is a default dimension that is available in Google Analytics

There are benefits of using the second approach is that, once you set the custom dimension with a user_id, you can use it most of the reports other than the event report.


Data can be extracted from Google Analytics using Core Reporting API

like image 97
Sudhir Mishra Avatar answered Oct 27 '22 11:10

Sudhir Mishra