Skip to content

Commit

Permalink
RSearchWordCloud
Browse files Browse the repository at this point in the history
Example R script of word cloud of search key words using RSiteCatalyst (Web Analytics using Adobe Analytics)
  • Loading branch information
adaish authored Jun 23, 2016
1 parent 50c1a2f commit df24487
Showing 1 changed file with 98 additions and 0 deletions.
98 changes: 98 additions & 0 deletions AdobeAnalyticsSearchWordCloudExample.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#---------Connecting to Adobe Analytics and creating Search Key Word's Word Cloud----------------------

#Author: Alice Daish (British Museum adaish@britishmuseum.org)
#January 2016
#https://github.com/BritishMuseum/RSearchWordCloud

#------------PACKAGE IN USE IS RSITECATALYST-----------------------------------------------------------
#https://github.com/randyzwitch/RSiteCatalyst

#------------INSTALL PACKAGES--------------------------------------------------------------------------
#install.packages("devtools")
library(devtools)
#install_github("randyzwitch/RSiteCatalyst", ref="master")
library(RSiteCatalyst)

#------Install dependant packages-----------------------------------------------------------------------
#install.packages("jsonlite")
#install.packages("plyr")
#install.packages("httr")
#install.packages("stringr")
#install.packages("digest")
#install.packages("base64enc")
#install.packages("RCurl")
library("jsonlite")
library("plyr")
library("httr")
library("stringr")
library("digest")
library("base64enc")
library("RCurl")

#-------Authentication----------------------------------------------------------------------------------
#Find web service credentials in User Managerment in the marketing cloud
#log in for adobe analytics
SCAuth("username:Company", "secretkey")

This comment has been minimized.

Copy link
@portableant

portableant Jun 23, 2016

Could you abstract the username and password into a separate config file?


#----------Explore Report Suite and Metrics, Evars and Props--------------------------------------------
#Report Suites
report_suites <- GetReportSuites()
report_suites

#Find eVars
eVars<-GetEvars("ReportSuite")
eVars

eVars[which(eVars$id =="evar1-search term"),] #search Term = word
eVars[which(eVars$id =="evar2-search results"),] #search results = freq

eVars$name

#Find metrics
metrics<-GetMetrics("ReportSuiteName")
metrics$id #list of metric id available

#Find elements
elements <- GetElements("ReportSuiteName")
elements$id #list of elements id available

#GetSuccessEvents
events <- GetSuccessEvents("ReportSuiteName")
events <- GetSuccessEvents(report_suites$rsid)
events

#GetProps
props <- GetProps("ReportSuiteName")
props

#-------------- Finding Top search words----------------------------------------------------------------
#Find top 500 search grouped from start of analytics to today
searchdata<-QueueRanked("ReportSuiteName",
date.from="2015-07-08", #start date for example "2015-07-08" to
date.to="2016-06-19", #end date for example "2016-06-19"
metrics=c("event1"), #Search Results -"event" need DTM name provided
elements=c("evar2"), #Search Term -"evar" need DTM name provided
search=c("::unspecified::","PDF*"),search.type="not", #exclude unwanted words
top=500)
View(searchdata) #view data

#---------------Create a Search Wordcloud----------------------------------------------------------------
#-------General WORD CLOUD ----------MAKE A PICTURE FOR ALL SEARCH CONTENT
#install.packages("wordcloud")
library(wordcloud)

#TOP 500 KEYWORD SEARCH TERMS
png("wordcloudkeywords.png", width=700,height=700) #create a png
#-------------WORDCLOUD RANDOM COLOURS ---------------------------
wordcloud(searchdata$name,searchdata$event1,scale=c(8,.2),
min.freq=2, #minimum count of words results
max.words=Inf, #max count of words results
random.order=FALSE, #largest word in the middle
random.color=TRUE, #change to FALSE of non-random colours
rot.per=.35, #text rotation
colors=brewer.pal(8, "Dark2"), #Choose colour palette
)
dev.off() #close and create png

#---------------------------------------------end--------------------------------------------------------

1 comment on commit df24487

@adaish
Copy link
Contributor Author

@adaish adaish commented on df24487 Jun 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did have it originally in a separate file but figured for the example it easier with everything in one script

Please sign in to comment.