20

This page indicates that it uses a custom user agent but it does not mention the name. I would like to be able to run some logic if the user agent is from PageSpeed. What is the name of the Google PageSpeed user agent?

Matty B
  • 1,008
  • 2
  • 13
  • 25

13 Answers13

15

The information in other answers is outdated: currently, Google PageSpeed does not pass the «Google Page Speed Insights» string in its User-Agent HTTP header, it passes the «Chrome-Lighthouse» string instead.
An example:

Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36(KHTML, like Gecko) Chrome/69.0.3464.0 Mobile Safari/537.36 Chrome-Lighthouse

Please note that the string is exactly «Chrome-Lighthouse» even if you run Google PageSpeed in other browsers (e.g. Firefox).

Dmitrii Fediuk
  • 434
  • 9
  • 11
  • 2
    Probably outdated now too, just tried it and neither **"Google Page Speed Insights"** or **"Chrome-Lighthouse"** work. – kilinkis Feb 15 '19 at 13:45
  • 1
    This does not work anymore. Page Speed Insights powered by Lighthouse uses a default userAgent, that cannot be detected anymore :( – PapaSoft Jun 01 '20 at 09:26
  • 1
    @PapaSoft that may have been true in June '20 but either way the API sends a 'Chrome-Lighthouse' user agent now (March '21) – Jake 1986 Mar 05 '21 at 04:05
  • @Jake1986 Right now PageSpeed *says* it sends a user-agent with "Chrome-Lighthouse", but in reality it doesn't do this at all. I echoed the user-agent and it was a completely different one. It didn't include anything like "lighthouse" or "pagespeed". – Stefan Teunissen Nov 19 '21 at 12:01
8

I created a script, it returns two USER AGENT one for desktop and other for mobile, these are

for MOBILE:

Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko; Google Page Speed Insights) Chrome/27.0.1453 Mobile Safari/537.36

FOR DESKTOP

Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko; Google Page Speed Insights) Chrome/27.0.1453 Safari/537.36

ghmulchandani
  • 304
  • 3
  • 19
7

In 2020 :

  1. Chrome-Lighthouse : for mobile
  2. Google Page Speed Insights : for desktop
nico_lrx
  • 715
  • 1
  • 19
  • 36
7

May 2020, there you go:

Mobile:

Mozilla/5.0 (Linux; Android 7.0; Mo to G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4143.7 Mobile Safari/537.36 Chrome-Lighthouse

Desktop:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4143.7 Safari/537.36 Chrome-Lighthouse

6

Update for March 2023

Google Page Speed Insights updated instance of Lighthouse to version 10.x and this event changes User-Agents:

For mobile:

Mozilla/5.0 (Linux; Android 11; moto g power (2022)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Mobile Safari/537.36"

For Desktop:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"

Passing Chrome-Lighthouse string has been stopped.

More details is here: https://github.com/GoogleChrome/lighthouse/pull/14384

Marcin Dargacz
  • 146
  • 1
  • 5
  • 2
    Oh no... now we have to remove all Google products that ***really*** were the cause for low LH scores. Google Analytics, Google Ad Manager, Google Tag Manager, Google AdSense just to name a few. Without these it was always 80-90%+ on LH. I guess it's 2 teams at Google. One that works on improving performance and one that kills it. Someone needs to get the two in touch, LOL... – fevangelou Mar 22 '23 at 09:45
  • I checked the access_logs today and they still included 'Chrome-Lighthouse' in the UA. – bokorben Apr 27 '23 at 13:02
5

I have just made a test, requested my site and checkout logs in real time.

User-Agent logs

Web Client test: @ https://developers.google.com/speed/pagespeed

date : "21/Feb/21"
user-agent-mobile : "Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.175 Mobile Safari/537.36 Chrome-Lighthouse",
user-agent-desktop :  "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.175"

node-cli lighthouse --version @ 7.1.0:

command : `lighthouse example.com --view`
date : "21/Feb/21"
user-agent-mobile : "Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4143.7 Mobile Safari/537.36 Chrome-Lighthouse",
user-agent-desktop :  "Mozilla/5.0 ($ENV_OS) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/$ENV_CHROME Safari/537.36"

Note that for the user-agent-desktop in the node-cli for test, there are two variables $ENV_OS and $ENV_CHROME which will vary according to the running envirmoent.

  • 2
    I just checked my access logs after running the API in both desktop and mobile and can confirm this is correct. – Jake 1986 Mar 05 '21 at 01:06
5

July 2021 (according to our logs):

Mobile agent is the same as in Ghassan Maslamanis answer from February 2021.

Desktop user agent is now:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.175 Safari/537.36 Chrome-Lighthouse

So they put the "Chrome-Lighthouse" back at the end of the string like they already did in May 2020 according to Oleg Kopachovets answer.

Grimm
  • 690
  • 8
  • 17
1

This source (http://riskyinternet.com/google-page-speed-insights-tool-open-for-use-by-scammers/) suggests that the UA string looks like this:

“Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.8 (KHTML, like Gecko; Google Page Speed Insights) Chrome/19.0.1084.36 Safari/536.8”

Stand__Sure
  • 253
  • 1
  • 13
1

Dec - 2019

Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3694.0 Safari/537.36 Chrome-Lighthouse

Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3694.0 Mobile Safari/537.36 Chrome-Lighthouse

Sjaak Wish
  • 455
  • 5
  • 8
0

Current data for today:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36(KHTML, like Gecko) Chrome/94.0.4590.2 Safari/537.36 Chrome-Lighthouse

-1

Checking the User Agent from Google Page Speed Insights these are the two instances of the service to check mobile and web

{   "pattern": "Chrome-Lighthouse",
    "instances": [
      "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3694.0 Safari/537.36 Chrome-Lighthouse",
      "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3694.0 Mobile Safari/537.36 Chrome-Lighthouse"
    ]}

i'm using these object to validate with a regex if the user agent is a bot

regex = RegExp("Chrome-Lighthouse","ig")
regex.test("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3694.0 Safari/537.36 Chrome-Lighthouse")
-2

This regex matches the UA as of the time of this answer:

// javascript PSI regex
navigator.userAgent.match(/nux.*oto\sG|x11.*fox\/54|x11.*ome\/39|x11.*ome\/62|oid\s6.*1.*xus\s5.*MRA58N.*ome|JWR66Y.*ome\/62|woobot|speed|ighth|tmetr|eadle/i)
// taken from WP plugin Fast Velocity Minify

Use it responsibly and avoid using document.write if you plan to inject js.

kilinkis
  • 584
  • 2
  • 13
  • 26
-3

Check if we have

like Gecko

In $_SERVER['HTTP_USER_AGENT']