# Attributing Time Spent in Third Party Domains

**URL:** <https://discuss.httparchive.org/t/attributing-time-spent-in-third-party-domains/584>\
**Category:** Analysis\
**Created:** [May 11, 2015, 10:39pm UTC](https://discuss.httparchive.org/t/attributing-time-spent-in-third-party-domains/584 "2015-05-11T22:39:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pganti](https://yyz1.discourse-cdn.com/flex035/user_avatar/discuss.httparchive.org/pganti/32/1299_2.png) [@pganti](https://discuss.httparchive.org/u/pganti)\
**Post date:** [May 11, 2015, 10:39pm UTC](https://discuss.httparchive.org/t/attributing-time-spent-in-third-party-domains/584/1 "2015-05-11T22:39:54Z")

</div>

I want to know whats the rough ballpark estimate for different third party domains when you insert a tag. I agree that some of these load in async so time spent is not a valid metric and obviously there’s this big debate on [what constitutes first party vs third party](http://bigqueri.es/t/what-is-the-distribution-of-1st-party-vs-3rd-party-resources/100). With all those caveats in, I write the following query which should give me the avg, median, p75 and p90/95 wall clock times attributed to the top third party domains:

```
SELECT DOMAIN(req.url) as domain, avg(req.time) as avg, NTH(50, quantiles(time)) p50,
  NTH(75, quantiles(time)) p75,
  NTH(90, quantiles(time)) p90,
  NTH(95, quantiles(time)) p95,count(*) as num_requests 
FROM [httparchive:runs.latest_requests] req JOIN (
  SELECT DOMAIN(url) self, pageid
  FROM [httparchive:runs.latest_pages]
  WHERE rank <= 1000
) as pages ON pages.pageid = req.pageid
WHERE DOMAIN(req.url) != pages.self
GROUP BY domain
order by num_requests desc
limit 100;

```

which yields the following results

![](https://yyz1.discourse-cdn.com/flex035/uploads/httparchive/517/c8172ba16ca597e7.png)

Is my method correct? Are there any other things I am missing?

---

<div class="post-metadata">

**Author:** ![igrigorik](https://yyz1.discourse-cdn.com/flex035/user_avatar/discuss.httparchive.org/igrigorik/32/925_2.png) [@igrigorik](https://discuss.httparchive.org/u/igrigorik)\
**Post date:** [May 11, 2015, 11:57pm UTC](https://discuss.httparchive.org/t/attributing-time-spent-in-third-party-domains/584/2 "2015-05-11T23:57:53Z")

</div>

The query looks reasonable. That said, for reasons you’ve mentioned, I’d be very careful with using this data for “attributing” slowness due to use of these origins – many of these fetches are non-blocking.
