With the OP's updated example as a list, we loop over the list, if the elements are not "null", then create a tibble, split the column at & with separate_rows and then split that column into multiple columns (separate), create a tibble from the named vector (deframe) with as_tibble_row)
library(dplyr)
library(tidyr)
library(tibble)
library(purrr)
map_dfr(lst1, ~ if(.x != "null") tibble(col1 = .x) %>%
separate_rows(col1, sep="&") %>%
separate(col1, into = c('col1', 'col2'), sep="\\=") %>%
deframe %>%
as_tibble_row())
-output
# A tibble: 4 x 6
# gclid utm_source utm_medium utm_campaign utm_term utm_content
# <chr> <chr> <chr> <chr> <chr> <chr>
#1 ertyyhglkdl-kjkY <NA> <NA> <NA> <NA> <NA>
#2 jhajsgjdgd_ajs google cpc 1234556 brand%20shirts Brand
#3 KvgMsEAAYASAAEgLq6vD_BwE google cpc 1674814043 brand%20shirts Brand
#4 <NA> fb ctw Shirt_rem <NA> CasciaShirt
Or instead of doing this in a loop, we can convert the list to a column in data.frame, do this once and pivot to wide format
library(data.table)
keep(lst1, ~ .x != "null") %>%
flatten_chr %>%
tibble(col1 = .) %>%
mutate(rn = row_number()) %>%
separate_rows(col1, sep='&') %>%
separate(col1, into = c('col1', 'col2'), sep="\\=") %>%
pivot_wider(names_from = col1, values_from = col2) %>%
select(-rn)
# A tibble: 4 x 6
# gclid utm_source utm_medium utm_campaign utm_term utm_content
# <chr> <chr> <chr> <chr> <chr> <chr>
#1 ertyyhglkdl-kjkY <NA> <NA> <NA> <NA> <NA>
#2 jhajsgjdgd_ajs google cpc 1234556 brand%20shirts Brand
#3 KvgMsEAAYASAAEgLq6vD_BwE google cpc 1674814043 brand%20shirts Brand
#4 <NA> fb ctw Shirt_rem <NA> CasciaShirt
data
lst1 <- structure(list("null", "gclid=ertyyhglkdl-kjkY", "utm_source=google&utm_medium=cpc&utm_campaign=1234556&utm_term=brand%20shirts&utm_content=Brand&gclid=jhajsgjdgd_ajs",
"utm_source=google&utm_medium=cpc&utm_campaign=1674814043&utm_term=brand%20shirts&utm_content=Brand&gclid=KvgMsEAAYASAAEgLq6vD_BwE",
"null", "null", "null", "null", "null", "null", "null", "null",
"null", "null", "utm_source=fb&utm_medium=ctw&utm_campaign=Shirt_rem&utm_content=CasciaShirt"), class = c("extracted",
"list"))