I'm excited about the possibilities with this package, as this new improved data is now available in a way to interact with all the thousands of other R packages.
If you'd like to see searchConsoleR capabilities, I have the package running an interactive demo here (very bare bones, but should demo the data well enough).
first application I'll talk about in this post is archiving data into a
.csv file, but expect more guides to come, in particular combining this
data with Google Analytics.
Automatic search analytics data downloads
The 90 day limit still applies to the search analytics data, so one of the first applications should be archiving that data to make year on year, month on month and general development of your SEO rankings.
The below R script:
- Downloads and installs the searchConsoleR package if it isn't installed already.
- Lets you set some parameters you want to download.
- Downloads the data via the search_anaytics function.
- Writes it to a csv in the same folder the script is run in.
- The .csv file can be opened in Excel or similar.
This should give you nice juicy data.
The first time you will need to run the scr_auth() script yourself so you can give the package access, but afterwards it will auto-refresh the authentication each time you run the script.
If you ever need a new user to be authenticated, run scr_auth(new_user=TRUE)
You may want to modify the script so it appends to a file instead, rather than having a daily dump, although I do this with a folder of .csv's to import them all into one R dataframe (which you could export again to one big .csv)
You can now take the download script and use it in automated batch files, to run daily.
In Windows, this can be done like this (from SO)
- Open the scheduler: START -> All Programs -> Accessories -> System Tools -> Scheduler
- Create a new Task
- under tab Action, create a new action
- choose Start Program
- browse to Rscript.exe which should be placed e.g. here:
- input the name of your file in the parameters field
- input the path where the script is to be found in the Start in field
- go to the Triggers tab
- create new trigger
- choose that task should be done each day, month, ... repeated several times, or whatever you like
In Linux, you can probably work it out yourself :)
Hopefully this shows how with a few lines of R you can get access to
this data set. I'll be doing more posts in the future using
this package, so if you have any feedback let me know and I may be able
to post about it. If you find any bugs or features you would like,
please also report an issue on the searchConsoleR issues page on Github.