Skip to content

Instantly share code, notes, and snippets.

@iamalexbirkett
iamalexbirkett / impact-estimator
Created November 15, 2019 19:27
Estimates the impact of getting placed on a given blog post/URL, assuming an average click through rate, conversion rate, etc.
serp_kw_volume = function(keyword, region)
{
base_url <- "https://api.semrush.com/"
## update with your own SEMRush API Key
query_params_2 = list(type = "phrase_all", key=api_key, phrase=keyword,
database=region)
@iamalexbirkett
iamalexbirkett / serp-tracker-scraper
Created November 8, 2019 16:23
pulls serp data from semrush, scrapes html from each page, and checks against the html for your url/link
# General-purpose data wrangling
#install.packages("tidyverse")
#install.packages("rvest")
#install.packages("rebus")
#install.packages("lubridate")
library(tidyverse)
library(httr)
# Parsing of HTML/XML files
library(rvest)
@iamalexbirkett
iamalexbirkett / ex-function-gist
Created November 8, 2019 14:57
example function
# this code doesn’t run, it’s just a comment telling you the next line
# will be a function that multiplies a variable by itself
times_two <- function(x) {
x * 2
}
install.packages("googleAnalyticsR", dependencies = TRUE)
## setup
library(googleAnalyticsR)
## This should send you to your browser to authenticate your email. Authenticate with an email that has access to the Google Analytics View you want to use.
ga_auth()
## get your accounts
account_list <- ga_account_list()
##load libraries
library(tidyverse)
library(httr)
## first we'll build a function to get the top keywoord for a single URL. We'll need to hook into SEMRush's API Here
get_top_kw <- function(page) {
base_url <- "https://api.semrush.com/"