Google Analytics 4 API requires the bcmath PHP extension to be installed but not every server will have it. To find out if you do type the following line in terminal.

php -r "print_r(get_loaded_extensions());"

The output will be something like you see below. On this instance you can see that I have bcmath installed already.

If you don’t have bcmath installed already then you’ll need to run the following command, assuming you have PHP 8.0 installed and that your server is uses apt to install its packages.

apt-get install php8.0@bcmath

Once that’s installed you’re ready to use Google Analytics 4 API to build your own analytics dashboard.

Posted by Curtis McHale

Web developer specializing in membership and ecommerce sites. I like to ride my bicycle.