Created
September 28, 2016 07:43
-
-
Save IronistM/5e83676152389628e624c559f845052c to your computer and use it in GitHub Desktop.
A function to check if custom dimensions work (via Pawel Kapuscinski)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(Rcpp) | |
library(RGA) | |
profiles <- list_profiles() | |
webIDs <- unique(profiles$webPropertyId) | |
col <- c("id","accountId","webPropertyId","name","index","scope","active","working") | |
for(i in webIDs){ | |
assign("dims", list_custom_dimensions(accountId = unlist(profiles[which(profiles$webPropertyId==i)[1],2]),webPropertyId = i,token=token)) | |
for(j in dims$id){ | |
test<-get_ga(unlist(profiles[which(profiles$webPropertyId==i)[1],1]), | |
start.date=start, | |
end.date=end, | |
metrics="ga:users,ga:sessions", | |
dimensions=j, | |
max.results = 3, | |
token=token) | |
Sys.sleep(1) | |
if ( is.null(test) ) { | |
row <- c(dims[ which(dims$id==j),c(1:7)],"no") | |
}else { | |
row <- c(dims[ which(dims$id==j),c(1:7)],"yes") | |
} | |
col<- rbind(col,row) | |
} | |
} | |
colnames(col)[ncol(col)] <- "working" | |
col<- tail(col,nrow(col)-1) | |
rownames(col) <- c(1:nrow(col)) | |
col<-as.data.frame(col) | |
col <- data.frame(lapply(col, as.character), stringsAsFactors=FALSE) | |
write.csv(col, "dimensions.csv") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment