i'm need export google analytics embed api chart png (or jpg) , excel.
my diagram work correctly , there isn't problem or error , want export data.
my current code is:
<!doctype html> <html> <head> <title>embed api demo</title> </head> <body> <section id="auth-button"></section> <h2>visits</h2> <fieldset> <legend>usersers & sessions on past week</legend> <section id="timelineweek"></section> </fieldset> <script> (function (w, d, s, g, js, fjs) { g = w.gapi || (w.gapi = {}); g.analytics = { q: [], ready: function (cb) { this.q.push(cb) } }; js = d.createelement(s); fjs = d.getelementsbytagname(s)[0]; js.src = 'https://apis.google.com/js/platform.js'; fjs.parentnode.insertbefore(js, fjs); js.onload = function () { g.load('analytics') }; }(window, document, 'script')); </script> <script> function buildoptions(haxis) { return { width: (window.innerwidth - 60), fontsize: 12, legend: { position: 'top', alignment: 'center', textstyle: { fontsize: 16 } }, series: { 0: { color: 'red' }, 1: { color: 'orange' } }, haxis: { title: haxis } }; } gapi.analytics.ready(function () { var gid = { query: { ids: 'ga:myaccountproperty' } }; var client_id = 'myssecretkey'; gapi.analytics.auth.authorize({ container: 'auth-button', clientid: client_id, }); var timelinetoday = new gapi.analytics.googlecharts.datachart({ reporttype: 'ga', query: { 'dimensions': 'ga:hour', 'metrics': 'ga:users,ga:sessions', 'start-date': 'today', 'end-date': 'today', },, chart: { type: 'line', container: 'timelineweek', options: buildoptions('date') } }); gapi.analytics.auth.on('success', function (response) { timelineweek.set(gid).execute(); }); }); </script> </body> </html>
there isn't native way export chart google analytics embed api there in visualization api. can either export data analytics reporting api, render library (like google visualization api) , export it, or tools take screenshots html2canvas.
Comments
Post a Comment