Easy user information entry using GoogleAnalyticsR

While playing around with R, and start using for marketing purposes, I found some processes that were tedious. So I made a workaround, which does take some of the work around getting the correct pieces of information mapped to the right variables using

UserInformation <- "axxxxxxxx wxxxxxxxxx pxxxxxxxxx" #Post URL Parameters
propertyID <- "UA-xxxxxxxx-1" # Property ID information
UserInformationSplit <- strsplit(UserInformation, " ")[[1]]
accountID <- UserInformationSplit[[1]]
viewID <- UserInformationSplit[[2]]
profileID <- UserInformationSplit[[3]]
accountID <- strsplit(accountID, split='a',)[[1]]
viewID <- strsplit(viewID, split='w',)[[1]]
profileID <- strsplit(profileID, split='p',)[[1]]
accountID <- accountID[2]
viewID <- viewID[2]
profileID <- profileID[2]

So to go through the code. UserInformation = here you post the part of the URL that starts with “a”. Make spaces in between them! And below the UA-credentials. I then used strsplit() to take the information and split it by ” “, which is the spaces mentioned above. we then uses the [] to locate the specific character we want.

accountID <- strsplit(accountID, split='a',)[[1]]
viewID <- strsplit(viewID, split='w',)[[1]]
profileID <- strsplit(profileID, split='p',)[[1]]

Later we want to split it on the right characters. “a”, “w “and “p”. lastly, we then asign them to correct variables, we then can use in main script for getting GoogleAnalytics Data from GoogleAnalyticsR

Leave a Reply