I am trying to access Google Analytics data with googleAnalyticsR but I find that I can access one site but not the other. I'm the admin for both properties and they both look the same to me when I'm using Google's Analytics web interface.
- https://mirror.shambhala.org (which is generated with Quarto) has this script in page headers:
<script async="" src="https://www.googletagmanager.com/gtag/js?id=G-RH1RGKF16D"></script>
- https://shambhala.org has this script in the page headers:
<script async src="https://www.googletagmanager.com/gtag/js?id=G-VD0TCNF8BF"></script>
Both sites appear in the GA Web interface; Google is collecting data, etc., etc.
Now I execute the following R code in Rstudio:
library(googleAnalyticsR)
library(tidyverse)
library(googlesheets4)
ga_auth(email = "my.admin.email.address@gmail.com")
account_list <- ga_account_list()
Here is the problem:
The second property shows up in the account_list data frame, but not the first.
And when I use the property number from the second property in the following code, I get good data:
df <- google_analytics("view-id-number",
date_range = c("2022-08-01", "2022-09-08"),
metrics = c("pageviews", "avgTimeOnPage" ),
dimensions = c("pagePath"),
anti_sample = TRUE)