SALURBAL Google Analytics Ingestions

Author

Ran Li (Maintainer)

Published

April 7, 2025

This notebook ingests google analytics data for our datawarehouse we will leverage the googleAnalyticsR package.

Properties

Lets get a list of all of our google analytics accounts - focusing on SALURBAL

Get SALURBAL GA properties
## All SALURBAL Properties
salurbal_ga = ga_account_list("ga4") %>% 
  filter(str_detect(property_name, "salurbal"))

## Portal Property
ga_portal = salurbal_ga %>% 
  filter(property_name == 'salurbal-data-portal')
property_id = ga_portal$propertyId

salurbal_ga

Here is a table of available dimensions and metrics available for us to analyze.

Google Analytics codebook
df_metrics_available = ga_meta(
  version = c("universal", "data"),
  propertyId = property_id,
  cached = TRUE,
  no_api = FALSE
) %>% 
  as_tibble()%>% 
  filter(status != "DEPRECATED")

df_metrics_available %>% 
  select(type, name = uiName, description) %>% 
  arrange(desc(type), name) %>% 
  reactable(searchable = TRUE)

Portal

Lets get some basic monthly information about SALURABL portal. Lets see what is available for this property.

Cohort Analysis

Chekc auth

Get cohorsts data

```{r}

ga_meta(
  version = c("data"),
  propertyId = property_id,
  cached = TRUE,
  no_api = FALSE
) %>% View()

 ga_data(
    property_id,
    metrics = c(
      "cohortActiveUsers", 
      "cohortTotalUsers"
    ),
    dimensions = c('cohort','cohortNthMonth'),
    date_range = c(start_date, end_date),
    limit = -1
  ) %>% 
    arrange(desc(date))
  
google_analytics(
  viewId = property_id,
  date_range = c(start_date, end_date),
  metrics = c("sessions"),
) 
```