Sorry about my english. I would like to get data from my Google Analytics. I show this api: https://developers.google.com/analytics/devguides/reporting/core/v4/
But I use the script and it doesn't return anything.
In my Google Analytics I have this:
I have a panel control with angular and html, and backend with sailsjs and nodejs, and I would like to show this data in my own panel control.
Like I say, I put this script in my html:
<script>
// Replace with your view ID.
var VIEW_ID = 'XXXXXXXX';
// Query the API and print the results to the page.
function queryReports() {
gapi.client.request({
path: '/v4/reports:batchGet',
root: 'https://analyticsreporting.googleapis.com/',
method: 'POST',
body: {
reportRequests: [
{
viewId: VIEW_ID,
dateRanges: [
{
startDate: '7daysAgo',
endDate: 'today'
}
],
metrics: [
{
expression: 'ga:sessions'
}
]
}
]
}
}).then(displayResults, console.error.bind(console));
}
function displayResults(response) {
var formattedJson = JSON.stringify(response.result, null, 2);
document.getElementById('query-output').value = formattedJson;
}
</script>
Thanks you!!
via oihi08

No comments:
Post a Comment