This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var https = require('https'), | |
key = 'key', | |
url = 'http://www.igvita.com/', | |
strategy = 'desktop'; | |
https.get({ | |
host: 'www.googleapis.com', | |
path: '/pagespeedonline/v1/runPagespeed?url=' + encodeURIComponent(url) + | |
'&key='+key+'&strategy='+strategy | |
}, function(res) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var SPREADSHEET_URL = "[YOUR_URL]"; | |
var DAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; | |
function main() { | |
var spreadsheet = SpreadsheetApp.openByUrl(SPREADSHEET_URL); | |
spreadsheet.getRangeByName("date").setValue(new Date()); | |
spreadsheet.getRangeByName("account_id").setValue(AdWordsApp.currentAccount().getCustomerId()); | |
var impressionsThreshold = parseField(spreadsheet.getRangeByName("impressions").getValue()); | |
var clicksThreshold = parseField(spreadsheet.getRangeByName("clicks").getValue()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Email Tracking with Google Analytics | |
==================================== | |
Written by Amit Agarwal on 09/24/2013 | |
Tutorial: http://labnol.org/?p=8082 | |
YouTube : http://youtu.be/9T_EqwQnZY0 | |
Support : http://twitter.com/labnol |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ip2Int <- function(ip){ | |
split <- as.numeric(strsplit(ip, "\\.")[[1]]) | |
out <- (split[1] * 256^3) + (split[2] * 256^2) + (split[3] * 256) + (split[4]) | |
return(out) | |
} | |
int2Ip <- function(int){ | |
split <- NULL | |
split[1] <- as.integer(int/256^3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Plot data using ggplot2 | |
library(ggplot2) | |
#Combine year/month/day together into POSIX | |
pageviews_w_forecast$date <- ISOdate(pageviews_w_forecast$year, pageviews_w_forecast$month, pageviews_w_forecast$day) | |
#Convert columns to numeric | |
pageviews_w_forecast$pageviews <- as.numeric(pageviews_w_forecast$pageviews) | |
pageviews_w_forecast$pageviews_upper <- as.numeric(pageviews_w_forecast$pageviews_upper) | |
pageviews_w_forecast$pageviews_lower <- as.numeric(pageviews_w_forecast$pageviews_lower) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load requirements to pull data from Google Analytics. | |
library(RGoogleAnalytics) | |
library(RColorBrewer) | |
library(scales) | |
library(lubridate) | |
library(ProjectTemplate) | |
library(ggplot2) | |
library(gridExtra) | |
library(plyr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in this case we want to load a 10% sampling set of the data | |
data: | |
LOAD ….<your fields>… | |
FROM <your QVD file> | |
WHERE ceil(rand() * 100) <= 10; // or: rand() <= 0.1 | |
// SAMPLE n LOAD is much faster but allocates the memory of the full data set during the LOAD | |
// Where rand() <= n allocates only the memory of the smaller result set which could be crucial with Big Data.. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LOAD | |
if(age<16, 'Under 16', | |
if(age>65, 'Over 65', | |
text(16+(Div(age-16,10)*10)) & ' - ' & text(25+(Div(age-16,10)*10)))) as age_group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
postDailyCustomDataSource = function(filename = "./YandexUpload/cost.data.splits.2013_02_11.csv", | |
accountId=GA.profiles$accountId[52], #uploading to 52nd accountId | |
webPropertyId=GA.profiles$webPropertyId[52], | |
customDataSourceId="XXXXX", | |
date = '2013-02-11', | |
access_token = MEtoken) { | |
# Verified this is correct URL as it works in curl | |
url2 <- paste0('https://www.googleapis.com/upload/analytics/v3/management/accounts/', accountId , | |
'/webproperties/', webPropertyId, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |