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
## GUIDE TO AUTH2 Authentication in R Shiny (or other online apps) | |
## | |
## Mark Edmondson 2015-02-16 - @HoloMarkeD | http://markedmondson.me | |
## | |
## v 0.1 | |
## | |
## | |
## Go to the Google API console and activate the APIs you need. https://code.google.com/apis/console/?pli=1 | |
## Get your client ID, and client secret for use below, and put in the URL of your app in the redirect URIs | |
## e.g. I put in https://mark.shinyapps.io/ga-effect/ for the GA Effect app, |
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
### Keybase proof | |
I hereby claim: | |
* I am MarkEdmondson1234 on github. | |
* I am marked (https://keybase.io/marked) on keybase. | |
* I have a public key whose fingerprint is 5D7E 6B62 C8C4 9CAB 9E8C 9004 C15F A69E 22CA F569 | |
To claim this, I am signing this object: |
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
<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','//www.google-analytics.com/analytics.js','ga'); | |
ga('create', 'UA-XXXXXX-X', 'auto', {'clientId': '{{clientId}}' }); | |
ga('send', 'pageview'); | |
ga('send', 'event','email','visit','email_content') |
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
class LandingPage(webapp2.RequestHandler): | |
"""Example page where content is - utm parameters should be used plus cid which will link the impression and visit """ | |
def get(self): | |
cid = cgi.escape(self.request.get('cid')) | |
clientId = getUniqueClientId(cid) | |
print clientId | |
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
def getUniqueClientId(seed=''): | |
"""Function to create the cid from the parameter passed in. Change this as needed """ | |
if seed: random.seed(seed) | |
## make this so its always unique by referring to a set or using md5 or something | |
theID = str(random.randint(1,9999)).zfill(4) + "-" + str(random.randint(1,9999)).zfill(4) + "-" + str(random.randint(1,9999)).zfill(4) + "-" + str(random.randint(1,9999)).zfill(4) | |
return theID | |
class ImageRequest(blobstore_handlers.BlobstoreDownloadHandler): |
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
class MainPage(webapp2.RequestHandler): | |
"""Get a URL, POST a GA hit""" | |
def get(self): | |
template_values = {} | |
template = JINJA_ENVIRONMENT.get_template('main.html') | |
self.response.write(template.render(template_values)) |
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
## do the causalImpact | |
# here the effect took place on the 200th day of the data imported, so the pre.period = 200 | |
# Data is examined and compared in the post perid to day 244 | |
impact <- CausalImpact(data = gadata$visits, | |
pre.period = c(1,200), | |
post.period = c(201,244), | |
model.args = NULL, | |
bsts.model = NULL, | |
post.period.response = NULL, | |
alpha = 0.05) |
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
## pull in the GA data | |
# get list of profiles | |
profiles <- ga$getProfiles() | |
# View the profiles table, and pick the profile you want and put in the profile ID below | |
UA <- "XXXXXXX" | |
# choose the dates you want to pull in data for | |
date_before = "2014-09-01" |
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
## Setup | |
## below only needed first time if you haven't the packages installed | |
# install.packages("devtools") | |
# library(devtools) | |
# devtools::install_github("google/CausalImpact") | |
## load the libraries | |
library(CausalImpact) | |
library(rga) |
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
#!/bin/bash | |
INPUT= | |
OUTPUT="output.txt" | |
COL=1 | |
while [ $# -gt 0 ] | |
do | |
case "$1" in | |
-f) INPUT="$2"; shift;; |