Skip to content

Instantly share code, notes, and snippets.

Mitch wmcraver

Block or report user

Report or block wmcraver

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@wmcraver
wmcraver / DocuSignDownloader.r
Last active Aug 7, 2018
This R script will login to your DocuSign account, retrieve a list of all envelopes, filter the list of envelopes for those with a status of 'completed', and then download said envelopes into one neat PDF. If you use this script, you will need to uncomment lines 5-7 and enter your username, password, and integrator key.
View DocuSignDownloader.r
library(docuSignr)
library(dplyr)
# Create env variables based on github directions for this package. https://github.com/CannaData/docuSignr
# Sys.setenv("docuSign_username" = "username")
# Sys.setenv("docuSign_password" = "password")
# Sys.setenv("docuSign_integrator_key" = "integrator_key")
login = docu_login()
@wmcraver
wmcraver / wordCap.js
Created Apr 6, 2017
Tealium Extension - capitalize first letter of each word in string
View wordCap.js
// b.channel = b.channel // The data layer value goes here. Should look like: one two three.
channelSplit = b.channel.split(" ");
for (i = 0; i < channelSplit.length; i++) {
channelSplit[i] = channelSplit[i].substring(0,1).toUpperCase() + channelSplit[i].substring(1,channelSplit[i].length);
}
b.channel = channelSplit.join(" "); // Change sectionName to the data layer variable. should look like: One Two Three.
@wmcraver
wmcraver / urltools.r
Created Jan 19, 2017
A quick script I use to extract key items from URLs. This makes quick work for double checking the structure of SEO/SEM URLs.
View urltools.r
library(urltools)
# Read in the URLs
dat = read.csv("LandingPageURLs.csv", stringsAsFactors = F)
# Extract the scheme, domain, and path from the urls
dat$scheme = scheme(dat$LandingPage)
dat$domain = domain(dat$LandingPage)
dat$path = path(dat$LandingPage)
@wmcraver
wmcraver / CapSectionName.js
Created Jan 17, 2017
Javascript extension for Tealium to capitalize the first letter of a section name so that they are consistent in the system.
View CapSectionName.js
sectionName = "word word word"; // The data layer value goes here. Should look like: best western rewards.
sectionNameSplit = sectionName.split(" "); // Split the sectionName into an array -- separator is a space.
for (i = 0; i < sectionNameSplit.length; i++) {
sectionNameSplit[i] = sectionNameSplit[i].substring(0,1).toUpperCase() + sectionNameSplit[i].substring(1,sectionNameSplit[i].length);
}
sectionName = sectionNameSplit.join(" "); // "Word Word Word" stored back in sectionName
// Change sectionName to value being sent to Analytics system from Tealium.
@wmcraver
wmcraver / hourlyRevByDOW.r
Last active Jan 16, 2017
Use rSiteCatalyst to get the average revenue by day of week and hour of day for the last 30 days.
View hourlyRevByDOW.r
library(RSiteCatalyst)
library(lubridate)
library(dplyr)
# SCAuth Info -------------------------------------------------------------
SCAuth(key = "", #fill in with your own info
secret = "", #fill in with your own info
company = "" #fill in with your own info
@wmcraver
wmcraver / rvesttest.r
Created Jan 13, 2017
Test Web Scraping
View rvesttest.r
library(rvest)
url2 = read_html("http://www.verticalmeasures.com/measurement-reporting/google-analytics-101-best-practices-for-ecommerce-websites/")
newxpath = as.character('//*+[contains(concat( " ", @class, " " ), concat( " ", "sidebar-widget", " " ))]//*[contains(concat( " ", @class, " " ), concat( " ", "sidebar-widget", " " ))]//ul')
titles = html_nodes(url2, css = "p")
titles = html_text(titles)
titles
@wmcraver
wmcraver / eVarsTesting.R
Last active Nov 22, 2016
Provides an way to check if eVars in Adobe Analytics are receiving data and also a way to see what the data look like.
View eVarsTesting.R
library(RSiteCatalyst)
library(dplyr)
library(lubridate)
SCAuth(
"key",
"secret",
"company"
)
@wmcraver
wmcraver / WriteXLS.R
Last active Nov 10, 2016
Write multiple data frames to multiple sheets in one spreadsheet
View WriteXLS.R
library(WriteXLS)
# renderedExperience, marketingChannel, allMetrics are data frames
sheetList <-list("Rendered Experience" = renderedExperience, "Marketing Channel" = marketingChannel, "Key Metrics" = allMetrics)
WriteXLS(
x = sheetList,
ExcelFileName = "RenderedExperience-MarketingChannel.xlsx",
SheetNames = names(sheetList),
View urlStatusChecker.R
urlStatusChecker = function(file,urlcol) {
library(httr)
dat = read.csv(file, stringsAsFactors = F)
for (i in 1:nrow(dat)) {
dat = dat[dat[urlcol] != "",]
dat = dat = dat[!is.na(dat[urlcol]),]
a = GET(dat[i,urlcol])
dat$URL[i] = a$url
View CheckURLs.R
library(httr)
library(stringr)
dat = read.csv("fileWithURLs.csv", stringsAsFactors = F)
---------------- for loop to get results ----------------
for (i in 1:nrow(dat)) {
a = GET(dat$Current.Forward[i])
dat$URL[i] = a$url
You can’t perform that action at this time.