Open tashburn opened 6 years ago
I'm currently facing the same issue trying to post data from the server to avoid ad-blockers. pageview()
works fine and the data shows up in the real-time list of active pages, but data posted with event()
does not show up anywhere as far as I can tell, even if I use "Daisy-chaining" to post the event together with a pageview.
Did you have any luck solving this @tashburn ?
EDIT: The event data is displayed in the report the day after, they just do not show up in the real time view. But somehow only the events label shows up, the category and action do not...
EDIT2:
Sending events using postman works and they are displayed in the real time view. Example post request: www.google-analytics.com/collect?v=1&t=event&tid=UA-XXXXXXXXX-1&cid=22981763-620f-4d2b-98c7-3c9f536d94be&ec=video&ea=play&el=holiday&ev=300
where UA-XXXXXXXXX-1 should be your Google analytics account id.
Using postman putting the data in the body as plain text also works and the event is displayed in the real-time view.
Example: https://www.google-analytics.com/collect
With Body: v=1&t=event&tid=UA-XXXXXXXXX-1&cid=22981763-620f-4d2b-98c7-3c9f536d94be&ec=video_postman&ea=play&el=holiday&ev=300
Could either of you post the exact call of the module for tracking the events that do not show up in Google Analytic's real-time reports?
I also encountered this issue.
// ga-test.js
const ua = require('universal-analytics');
const visitor = ua('<My UA ID>');
visitor
.event({
ec: 'Fake',
ea: 'Fake action',
})
.send();
node ga-test.js
After some short delay (< 20s), a event shows up in real time report (under Reports > Real-time > Events)
No events shown in the real time report on google anaytics.
When request
's debug flags are turned on (by DEBUG=universal-analytics NODE_DEBUG=request
), I can see the request body being:
ec=Fake&ea=Fake%20action&v=1&tid=<My UA ID>&cid=<random UUID>&t=event
It looks totally legit.
Hi,
I found that if I send the action along with screenview, then it will show up. Maybe pageview will have the same effect.
Reproduce:
const ua = require('universal-analytics');
const visitor = ua('<UA ID>');
visitor.screenview({
screenName: 'FakeScreen',
applicationName: 'Fake app',
});
visitor
.event({
ec: 'Fake',
ea: 'Fake action',
})
.send();
<UA ID>
with yoursThen you should see the pageview & event coming to the report.
I haven't had any issue using this from the server side the following way:
const visitor = ua(this.googleAnalyticsTrackingId, this.sessionId, {
uid: this.deviceId,
});
visitor.event(
this.getGoogleAnalyticsCategory(),
this.getGoogleAnalyticsAction(),
this.getGoogleAnalyticsLabel(),
this.getGoogleAnalyticsValue(),
this.getGoogleAnalyticsPath(),
(err) => {
if (err) {
this.logger.error(JSON.stringify(err, null, 2), 'sendGoogleAnalyticsStatistics');
Raven.captureMessage(err, { level: 'error' });
}
},
);
Maybe it doesn't behave correctly using the .event(object).send()
, I use the callback way
Same here, no real-time data.
Just sending a got.post()
request makes it appearing in real-time GA report page.
await got.post('https://www.google-analytics.com/collect?v=1&t=pageview&tid=UA-XXXXXXXX-XX&cid=22981763-620f-4d2b-98c7-3c9f536d94be&dp=video')
I'm starting to use
universal-analytics
exclusively on the server-side. My browser clients send custom events to my servers, and my servers then post events to google analytics usinguniversal-analytics
.I'd love to somehow accomplish GA's "real-time" abilities with my setup, where I know real-time info about clients. Can this be done with
universal-analytics
from the server-side?If
universal-analytics
is already capable and I missed it in the documentation, please let me know how to do it.