Reputation: 934
Evening,
While coding a javascript using Google analytics API to display data on a backoffice. I stumble around a weird problem related to the ga:users metric.
I have a graph that displays ga:users and ga:pageviews for a given year. And a select box with various years since the site was launched.
It runs this code
reportChart = new gapi.analytics.googleCharts.DataChart({
query: {
'ids': 'ga:6XXXXXXX',
'start-date': '2015-01-01',
'end-date': '2015-12-31',
'metrics': 'ga:users,ga:pageviews',
'dimensions': 'ga:date'
},
chart: {
'container': 'graficoIndex',
'type': 'LINE',
'options': {
'width': '100%',
'height': '230px'
}
}
});
reportData = new gapi.analytics.report.Data({
query: {
'ids': 'ga:6XXXXXXX',
'metrics': 'ga:pageviews, ga:users, ga:sessions, ga:percentNewSessions, ga:pageviewsPerSession',
'dimensions': 'ga:date',
'start-date': '2015-01-01',
'end-date': '2015-12-31'
}
});
reportChart.execute();
reportData.execute();
And on select box change I just execute a different query and chart with the new start-date and end-date.
Now to the problem: all seems fine after 22 of August 2016 but before that the metric ga:users is always zero.
Going to the Query explorer at https://ga-dev-tools.appspot.com/query-explorer/ I confirmed this getting zero for ga:users from 01/01/2014 to 31/12/2014 (but strangely I did get a real value when I tried ga:newUsers)
What is strange is that on analytics.google.com I get real values for Users pre-2016 dates.
Anybody knows what's wrong here? Was ga:users a substitute metric for some old deprecated one on august 2016? I read somewhere that once was a ga:visitors metric now deprecated.
Thanks in advance
Upvotes: 1
Views: 493
Reputation: 70
I just discovered this same problem! If my request for ga:users has a start date before 23-Aug-2016 I get only zeros for users, though non-zero numbers are reported at analytics.google.com, and I can get ga:newUsers just fine.
I would say ga:newUsers is the most reasonable substitute, though it will always undercount users.
If you turn off the new calculation method (as described in the support doc linked to by commenter Bronwyn V, above), you will get numbers for ga:users prior to 23-Aug-2016.
Upvotes: 2