Use google analytics on endpoint


So i have these endpoints on my site, which aren’t HTML pages, they’re built like:

app.get(’/api/v1/panda/fact’, function (request, response) {
const db = require(’./db/panfacts.json’)
let fact = db[Math.floor(Math.random() * 36)].fact;
let entry = db[Math.floor(Math.random() * 36)].entry;
response.send({“object”: {“entry”:entry, “fact”:fact},});

So, how would i be able to add something so google analytics can collect data on this?


Hey @SammyWhamy someone else might have direct experience they can share, but you might find it useful to look at or perhaps the universal-analytics package as places to start.

Let us know how it goes!