I have this js to render charts from Google Analytics data below using the ga-ez-dash library to show user visits history, browser history etc. I am able to render charts but the problem is that I dont want all of my clients to login with our Google Analytics Account.Is there any way to make the login automatic through a jquery post/curl php etc or can i make the Google Analytics data public.Can anyone suggest the best way to achieve this.Any help would be greatly appreciated guys!
var API_KEY = 'Enter Your API Key Here';
var CLIENT_ID = 'Enter Your Client ID Here';
var TABLE_ID = 'Enter your Table ID here';
// Format of table ID is ga:xxx where xxx is the profile ID.
gadash.configKeys({
'apiKey': API_KEY,
'clientId': CLIENT_ID
});
// Create a new Chart that queries visitors for the last 30 days and plots
// visualizes in a line chart.
var chart1 = new gadash.Chart({
'type': 'LineChart',
'divContainer': 'line-chart-example',
'last-n-days':30,
'query': {
'ids': TABLE_ID,
'metrics': 'ga:visitors',
'dimensions': 'ga:date'
},
'chartOptions': {
height:600,
title: 'Visits in January 2011',
hAxis: {title:'Date'},
vAxis: {title:'Visits'},
curveType: 'function'
}
}).render();
You can log into Google services with an OAuth2 token; just get the user to log in once to their Google account, approve your access and store the token. Then you can log into the portion of their account you have access to automatically.
P.S. To do it in Javascript, they provide a client API. All client APIs listed at the bottom of the first page I linked to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With