One of the ways for getting Google Analytics data in R is using the excellent package googleAnalyticsR.
GA4 and Big Query But suppose you are curious about trying (the new) GA4 because the old one is going away, and you set it up on your site (like I did on the Discindo blog).