MarkEdmondson1234/ga-dashboard-demo

Question about MySQL persistent data and Analytics

diegocgaona opened this issue · 2 comments

Hi Mark,

Thanks for your great job!

I have a doubt, It's possible to save the data from GA to a MySQL database?
I say this, because I could want to save some data and consult on my own database without query the GA API. (I think this could be more useful with others APIs, who don't let you access data for more than 3 months past, I think Facebook do it)

You think this is possible, or would be much complex?

Thanks!!

Hi @diegocgaona , yes its perfectly possible, download the GA data then upload to MySQL using the functions provided.

Pseudo code, but something like:

## load the functions.R file 
source('functions.R')

## Run this locally first, to store the auth token.
rga.open(where="token.rga")

## fetch your GA data - defaults to all available data
gadata <- get_ga_data(profileID = XXXX, fetch_metrics = 'ga:sessions', fetch_dimensions = 'ga:medium')

## assuming you have set up MySQL details in secrets.R
createTable("sql_databased_name", gadata)

Thanks Mark!!!
Very helpful. I will try this.