Created
May 10, 2012 21:04
-
-
Save mrpatrick/2655886 to your computer and use it in GitHub Desktop.
Google Analytics Easy Dashboard Javascript Library demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE> | |
<html> | |
<head><title>GA Dash Demo</title></head> | |
<body onload="chart1.render();" > | |
<!-- Add Google Analytics authorization button --> | |
<button id="authorize-button" style="visibility: hidden"> | |
Authorize Analytics</button> | |
<!-- Div element where the Line Chart will be placed --> | |
<div id='line-chart-example'></div> | |
<!-- Load all Google JS libraries --> | |
<script src="https://www.google.com/jsapi"></script> | |
<script src="assets/gadash-1.0.js"></script> | |
<script src="https://apis.google.com/js/client.js?onload=gadashInit"></script> | |
<script> | |
// Configure these parameters before you start. | |
var API_KEY = 'xxx'; | |
var CLIENT_ID = 'xxx'; | |
var TABLE_ID = 'ga:xxx'; | |
// 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 the last 30 days', | |
hAxis: {title:'Date'}, | |
vAxis: {title:'Visits'}, | |
curveType: 'function' | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Needed to update my browser. That was the culprit. Thanks
Hey would you know how to use this library to get data without the chart?
@tlaverdure - I think you'll have to use the Core Reporting API if you want access to the actual data rather than a chart (you could also use the Table chart if you'd rather a spreadsheet-rendered version of the data: 'type':'Table'
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Weird - it seems to work in both FF (12.0) and Safari (5.15) for me - however, I did notice it took a few seconds longer to load in safari. Are you getting any errors in firebug?