Skip to content

Instantly share code, notes, and snippets.

View wmcraver's full-sized avatar
🌵
Learning some new things

Mitch wmcraver

🌵
Learning some new things
View GitHub Profile

Keybase proof

I hereby claim:

  • I am wmcraver on github.
  • I am wmcraver (https://keybase.io/wmcraver) on keybase.
  • I have a public key ASDv3elJFsMoaaq0IqLzC_Y_QBfCbmLhhTbTZvVxQTLBVwo

To claim this, I am signing this object:

@wmcraver
wmcraver / DocuSignDownloader.r
Last active November 15, 2020 08:54
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.
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 April 6, 2017 22:45
Tealium Extension - capitalize first letter of each word in string
// 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 January 19, 2017 23:08
A quick script I use to extract key items from URLs. This makes quick work for double checking the structure of SEO/SEM URLs.
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 January 17, 2017 00:33
Javascript extension for Tealium to capitalize the first letter of a section name so that they are consistent in the system.
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 January 16, 2017 22:54
Use rSiteCatalyst to get the average revenue by day of week and hour of day for the last 30 days.
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 January 13, 2017 00:10
Test Web Scraping
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 November 22, 2016 18:48
Provides an way to check if eVars in Adobe Analytics are receiving data and also a way to see what the data look like.
library(RSiteCatalyst)
library(dplyr)
library(lubridate)
SCAuth(
"key",
"secret",
"company"
)
@wmcraver
wmcraver / WriteXLS.R
Last active November 10, 2016 23:28
Write multiple data frames to multiple sheets in one spreadsheet
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),
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