0

Im building a script which is to intercept all Google Analytics pageview hits from a site, and it works fine for most requests, but I have one type where a 3rd party script injects this tag below and the pageview-call very late in the loading process, and Puppeter doesn't seem to recognize these requests even though Chrome devtools show them.

Edit: it's not just the GA pageview hit that Puppeter is missing, it's several requests that are made at the end of loading.

<script async="" src="//www.google-analytics.com/analytics.js"></script>

Any ideas on how I can get Puppeteer to show me all requests?

Jonas Bolin
  • 606
  • 1
  • 11
  • 28
  • Does this answer your question? [Best way to intercept XHR request on page with Puppeteer and return mock response](https://stackoverflow.com/questions/46365972/best-way-to-intercept-xhr-request-on-page-with-puppeteer-and-return-mock-respons) – ggorlen Oct 31 '20 at 01:23

1 Answers1

1

You can use the setRequestInterception method to block scripts the page is making regardless of who initiated. There's a great example here: https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagesetrequestinterceptionvalue

browserless
  • 2,090
  • 16
  • 16