Skip to content

Instantly share code, notes, and snippets.

View IronistM's full-sized avatar
🏗️
Under construction

Manos Parzakonis IronistM

🏗️
Under construction
View GitHub Profile
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) {
@IronistM
IronistM / Account Anomaly Detector.js
Last active December 19, 2016 15:08
Just commented out the two lines that falsly set todays click and impression stats to 0. "Account Anomaly Detector alerts the advertiser whenever an AdWords account is suddenly behaving too differently from what's historically observed. When an issue is encountered, the script will send the user an alerting email. Only a single email for an aler…
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());
@IronistM
IronistM / track_email_opens.js
Last active January 26, 2018 16:45
How to Track Gmail Messages with Google Analytics modified for Universal Analytics tracking. You will need to copy this spreadsheet http://goo.gl/Tk1nR8 and then open Tools > Script Editor to replace the existing code or simply add the /* Universal Analytics Tracking */ part
/*
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
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)
#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)
@IronistM
IronistM / initiate_RGoogleAnalytics.r
Created October 10, 2013 19:01
Basic plotting of AOV, Conversion rate & Goal completion for a A/B Test across 3 domains. (#GoogleAnalytics and #ContentExperiments)
# Load requirements to pull data from Google Analytics.
library(RGoogleAnalytics)
library(RColorBrewer)
library(scales)
library(lubridate)
library(ProjectTemplate)
library(ggplot2)
library(gridExtra)
library(plyr)
// 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..
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
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,
@IronistM
IronistM / 0_reuse_code.js
Created November 10, 2013 22:47
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console