Why the Google Analytics API is eating the "\" in my filter query? -
i playing google analytics api , found interesting. today came problem can't solved.
i sending filter this:
'filters':'ga:pagepath=~^/q-\d+/\d+$'
it's working in query explorer not working code.
after tests found query wrong when it's sent. here "network" panel of chrome debugging tool:
as in picture, \d
became d
, guess reason data not correctly showing up.
how can fix this?
here code:
var o ={ 'ids': 'ga:' + profileid, 'start-date': $('#startdate').val(), 'end-date': $('#enddate').val(), 'metrics': 'ga:pageviews,ga:uniquepageviews', 'dimensions': 'ga:pagepath', 'sort':'ga:pagepath', 'filters':'ga:pagepath=~^/q-\d+/\d+$' }; gapi.client.analytics.data.ga.get(o) .then(function(response) {
thanks,
you need escape backslash symbols:
'filters':'ga:pagepath=~^/q-\\d+/\\d+$'
this can checked:
console.log('ga:pagepath=~^/q-\\d+/\\d+$'); console.log('ga:pagepath=~^/q-\d+/\d+$');
if using custom events in ga can take @ http://mixpanel.com or http://www.devmetrics.io, provide better event model , event oriented api / ui.
Comments
Post a Comment