React-beginner
React-beginner

Reputation: 115

How to Detect If the Current Visitor is PageSpeed Insights or Lighthouse

I want to selectively disable Google Analytics (GA) when the page is accessed by PageSpeed Insights or Lighthouse to improve performance scores. Is there a reliable way to determine if the current visitor is one of these tools?

I have tried using the isbot package to detect Lighthouse based on the user-agent, but it doesn’t seem to work. Any suggestions?

Upvotes: -1

Views: 30

Answers (1)

kwk9k
kwk9k

Reputation: 9

I don't understand why you want to falsify the results.

If you want to skip Google Analytics when loading the page, try excluding the code responsible for GA using Chrome Dev Tools (Network tab, then block specific URL paths that are responsible for GA).

Upvotes: -1

Related Questions