Advertisement
NonplayerCharacter

R + GA | Browser versions

Feb 9th, 2018
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.97 KB | None | 0 0
  1. # Look at the major versions of browsers being used by your users
  2. # by jwgayler @ Measure Slack
  3.  
  4. ga_auth()
  5.  
  6. #Alter filter to look at OS of choice
  7. browser_type <- google_analytics(id = your_ga_id,
  8.                                  start = date_start,
  9.                                  end = date_end,
  10.                                  metrics = "sessions",
  11.                                  dimensions = c("browser", "browserVersion"),
  12.                                  filters = "ga:operatingSystem==Windows",
  13.                                  max = 9999
  14.                                  )
  15. # Extract major browser version and sort dataframe
  16. browser_type <- browser_type %>%
  17.   arrange(-sessions) %>%
  18.   mutate(major_version = str_sub(browserVersion, end = 2)) %>%
  19.   group_by(browser, major_version) %>%
  20.   summarise(session_count = sum(sessions)) %>%
  21.   arrange(-session_count) %>%
  22.   ungroup() %>%
  23.   mutate(proportion = scales::percent(session_count / sum(session_count)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement