Skip to content

Instantly share code, notes, and snippets.

@ryanpraski
ryanpraski / real-time_adobe_analytics_multiple_filters.json
Created September 8, 2016 14:31
Multiple filters to an Adobe Analytics real-time API query
{
"reportDescription":{
"source": "realtime",
"reportSuiteID":"rtd-example",
"metrics":[
{"id":"pageviews"}
],
"elements": [
{
"id": "page",
{
"real_time_settings":[
{
"metric":"instances",
"elements":[
"page", "sitesection", "referringdomain"
],
"min_granularity":"1",
"name":"Content Real Time Report",
"ui_report":"true"
@ryanpraski
ryanpraski / apple_health_load_analysis_R.r
Last active April 30, 2023 21:08
Load Apple Health Kit export.xml file in R then analyze and visualize Steps Data using R. See the full post here: http://www.ryanpraski.com/apple-health-data-how-to-export-analyze-visualize-guide/
library(dplyr)
library(ggplot2)
library(lubridate)
library(XML)
#load apple health export.xml file
xml <- xmlParse("C:\\Users\\praskry\\Desktop\\apple_health_data\\export.xml")
#transform xml file to data frame - select the Record rows from the xml file
df <- XML:::xmlAttrsToDataFrame(xml["//Record"])
@ryanpraski
ryanpraski / apple_health_analysis_R.r
Created July 14, 2016 21:21
Analyze and Visualize Apple Health Kit Steps Data using R
library(dplyr)
library(ggplot2)
library(lubridate)
#load steps data into data frame
dfsteps <- read.csv("C:\\Users\\praskry\\Desktop\\apple_health_data\\StepCount.csv")
str(dfsteps)
#make endDate in a date time variable POSIXct using lubridate with eastern time zone
dfsteps$endDate <-ymd_hms(dfsteps$endDate,tz="America/New_York")
@ryanpraski
ryanpraski / salesforce_adwords_google_analytics_integration_web-to-lead_form_example.html
Last active January 8, 2020 23:09
Sample Salesforce web-to-lead form that captures Adwords GCLID in a hidden form field & Google Analytics Visitor ID in another hidden form field. Make sure to replace xxxxx, yyyyy, zzzzz with your specific Salesforce field values. Include your Google Analytics Tracking ID. Create a User Scope custom dimension in your Google Analytics property Ad…
<!DOCTYPE html>
<html>
<head>
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8">
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
@ryanpraski
ryanpraski / salesforce_adwords_integration_web-to-lead_form_example.html
Last active December 16, 2020 14:00
Sample Salesforce web-to-lead form that captures Adwords GCLID in a hidden form field. Make sure to replace xxxxx and yyyyy with your specific Salesforce field values.
<!DOCTYPE html>
<html>
<head>
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8">
</head>
<body>
<form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST">
<script>
@ryanpraski
ryanpraski / costdata.gs
Last active January 19, 2021 17:03 — forked from chipoglesby/costdata.gs
Cost Data Upload via Google Analytic's Management API with Google Sheets
function uploadData() {
var accountId = "xxxxxxxx";
var webPropertyId = "UA-xxxxxxxx-x";
var customDataSourceId = "xxxxxxxx";
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var maxRows = ss.getLastRow();
var maxColumns = ss.getLastColumn();
var data = [];
for (var i = 1; i <= maxRows; i++) {
data.push(ss.getRange([i], 1, 1, maxColumns).getValues());
@ryanpraski
ryanpraski / nonbrand_keyword_dataviz_Rshiny_searchConsoleR.R
Last active April 12, 2016 18:06
Shiny app to visualize clicks, impressions, and position by week for Google Organic non brand keywords. Uses searchConsoleR library to pull Google Search Console data.
library(shiny)
library(ggvis)
runApp(shinyApp(
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
uiOutput("choose_dataset")
),
mainPanel(ggvisOutput("plot1"), ggvisOutput("plot2"), ggvisOutput("plot3"))
)
@ryanpraski
ryanpraski / google_search_console_daily.R
Last active April 27, 2021 06:49
Download Google Search Console data (formerly webmaster tools) to R using searchConsoleR package. This script downloads data for the most recent day of search console data which is 3 days ago. Tutorial describing how to automate daily Google Search Console pulls using this script: http://www.ryanpraski.com/google-search-console-api-r-guide-to-ge…
## A script to download and archive Google search console analytics (formerly webmaster tools)
##
## searchConsoleR package created by Mark Edmondson (http://markedmondson.me)
##
## This script downloads and writes data to .csv for the most recent day of search console data (3 days ago)
## load the required libraries
## (Download them with install.packages("googleAuthR") and install.packages("searchConsoleR") if necessary
library(googleAuthR)
library(searchConsoleR)
@ryanpraski
ryanpraski / google_search_console_90_days.R
Last active April 5, 2016 16:13
Download Google Search Console data (formerly webmaster tools) to R using searchConsoleR package. This script downloads the last 90 days of available data: from 93 days ago to 3 days ago and write the data to a .csv file.
## A script to download and archive Google search console analytics (formerly webmaster tools)
##
## searchConsoleR package created by Mark Edmondson (http://markedmondson.me)
##
## This script downloads and writes data to .csv for the last 90 days of data available
## load the required libraries
## (Download them with install.packages("googleAuthR") and install.packages("searchConsoleR") if necessary
library(googleAuthR)
library(searchConsoleR)