segment-integrations / analytics.js-integration-google-analytics

The Google Analytics analytics.js integration.
https://segment.com/docs/integrations/google-analytics/
MIT License
20 stars 23 forks source link

Support for User Timing API #42

Open pastelsky opened 7 years ago

pastelsky commented 7 years ago

Is there a way to send custom metrics like user timings through segment ? This is supported by google analytics.

hankim813 commented 7 years ago

@pastelsky hmm I'm not sure how this would fit given Segment's API spec. It wouldn't really be mapped to .identify() or .track() since we don't have any events spec'd when it comes to tracking user timing. So I'd imagine without a strong case around viable GA User Timing API <> Segment API mapping, we probably won't support this.

dazulu commented 7 years ago

Just dropping in to say that I'd love to see this supported. I would use it to send client side performance metrics to GA's Site Speed User Timings section.

hankim813 commented 7 years ago

@dazulu we still haven't heard much request for this feature and hasn't been something we prioritized. We do accept PRs :)

For now, you can just do this directly

// .ready ensures the ga integration has been initialized, so its safe to reference third party sdk window objects in the callback

analytics.ready(function() {
   // Feature detects Navigation Timing API support.
  if (window.performance) {

   // Gets the number of milliseconds since page load
   // (and rounds the result since the value must be an integer).
   var timeSincePageLoad = Math.round(performance.now());

   // Sends the timing hit to Google Analytics.
   window.ga('send', 'timing', 'JS Dependencies', 'load', timeSincePageLoad);
  }
});
chollier commented 6 years ago

I would love to see this prioritized as well

ryzy commented 6 years ago

👍

SegmentDestinationsBot commented 5 years ago

Hi @pastelsky, as part of the monorepo migration, this issue has been moved to new issue. Our engineers have been notified and will prioritize and work on it ASAP. Thank you!

For more information, see README.md.