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:

enter image description here

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

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -