Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
147 views
in Technique[技术] by (71.8m points)

javascript - Google Reporting API return event actions for category

I'm trying to return all given actions for a particular event category via my Node JS application that's fetching data from the Google Reporting API V3. I'm able to fetch everything with...

app.get('/api', async (req, res) => {
  const response = await jwt.authorize()
  const result = await google.analytics('v3').data.ga.get({
    'auth': jwt,
    'ids': `ga:${viewId}`,
    'start-date': '30daysAgo',
    'end-date': 'today',
    'dimensions': 'ga:eventCategory,ga:eventAction',
    'metrics': 'ga:uniqueEvents'
  })

  res.send(result)
})

But as soon as I add a filter it doesn't work, no data is returned despite the 200 status code:

app.get('/api', async (req, res) => {
  const response = await jwt.authorize()
  const result = await google.analytics('v3').data.ga.get({
    'auth': jwt,
    'ids': `ga:${viewId}`,
    'start-date': '30daysAgo',
    'end-date': 'today',
    'filters': 'ga:eventCategory==Honeycomb:%20Core',
    'dimensions': 'ga:eventCategory,ga:eventAction',
    'metrics': 'ga:uniqueEvents'
  })

  res.send(result)
})

From my understanding, spaces have to be encoded, which is what I've done, but no data is returned, am I missing something? My event category is called: Honeycomb: Core in Google Analytics.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try 'filters': 'ga:eventCategory%3D%3DHoneycomb:%20Core'

Look at the table of filter operators in the reference link you posted. The "==" should be encoded as well.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...