Can I change the user-agent when generating a lighthouse report?

Viewed 1385

I am trying to run a page performance report through lighthouse using a search engine crawler user-agent (such as Googlebot) rather than the default lighthouse user-agent. I can't see anywhere in lighthouse where it's possible to specify an alternate user-agent, so was wondering if it's possible?

Thanks

1 Answers

This can be achieved with --chrome-flags in the CLI.

The complete list of chrome flags is available here, I have quick-linked to the relevant flag, which is --user-agent.

Please note: in order to use this you have to switch off device emulation otherwise the user agent you set will get overridden. As such you may need to set height and width etc. (Which can be done with --window-size=360,640);

lighthouse https://example.com --disable-device-emulation --chrome-flags="--user-agent=**YOUR USER AGENT** --window-size=360,640".

Related