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
/* | |
* | |
* Pop this puppy into your Chrome console on a page where you need to observe changes to the dataLayer | |
* http://updates.html5rocks.com/2012/11/Respond-to-change-with-Object-observe | |
* | |
*/ | |
function chaChaChaChaChanges(changes) { | |
n = dataLayer.length-1; | |
console.dir(dataLayer[n]); |
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
from apiclient import errors | |
from apiclient.discovery import build | |
from oauth2client.client import OAuth2WebServerFlow | |
import httplib2 | |
import json | |
# easy access to account/view/property when using multiple accounts (e.g., ios app, android app, website) | |
with open('/Users/adrianp/py/json/ga_cred.json') as p: | |
gc = json.load(p) | |
p.close() |
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
import pandas as pd | |
import numpy as np | |
from sqlalchemy import create_engine | |
# what is the database equivalent of 'hello world' anyways? | |
test_query = """ | |
SELECT COUNT(*) | |
FROM core.users a | |
WHERE a.date BETWEEN '2015-01-01' AND '2015-05-31' | |
GROUP BY 1 |
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> | |
console.log("outside test function"); | |
+function ($) { | |
console.log("inside test function"); | |
if (typeof $ == 'undefined') { | |
console.log("no jquery!"); | |
} else { | |
console.log("test function made it past check!"); | |
} | |
}(window.jQuery); |
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
import json | |
import mysql.connector | |
import numpy as np | |
import pandas as pd | |
from pandas import Series, DataFrame | |
# p as path, c as connection | |
with open('/Users/path/to/database/keys/prod_db.json') as p: | |
c = json.load(p) | |
p.close() |
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
// all of this is made possible by the optimizely javascript api, specifically: | |
// http://developers.optimizely.com/javascript/reference/#the-data-object | |
function getExperiments() { | |
var experimentInfo = {}; | |
var wasRedirected = false; | |
/* | |
* create an array of experiments that are active on the page | |
* you must pass two tests to be placed in an active experiment: | |
* 1) url targeting: https://help.optimizely.com/hc/en-us/articles/200040835-URL-Targeting-Choose-where-your-experiment-runs |
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
MktoForms2.loadForm("//app-sjst.marketo.com", "785-UHP-775", 1057, function(form) { | |
// Add an onSubmit handler | |
form.onSubmit(function(){ | |
// Get the form field values | |
var vals = form.vals(); | |
// You may wish to call other function calls here, for example to fire google analytics tracking or the like | |
// callSomeFunction(vals); | |
// We'll just alert them to show the principle | |
alert("Submitted values: " + JSON.stringify(vals)); | |
}); |
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> | |
MktoForms2.whenReady(function (form) { | |
form.onSubmit(function(){ | |
var vals = form.vals(); | |
dataLayer.push({ | |
'event': 'marketoFormSubmit', | |
'marketoCompany': vals['Company'], | |
'marketoLeadSource': vals['LeadSource'], | |
'marketoOriginalSource': vals['Original_Source_Detail__c'], | |
'marketoCurrentSource': vals['Source_Detail__c'] |
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> | |
// all the marketo from 2.0 javascript has successfully loaded, so we can continue | |
MktoForms2.whenReady(function (form) { | |
// the user has just submitted the form | |
form.onSubmit(function(){ | |
// marketo provides a form object with a nifty method to get the values from the form | |
// we'll store those values in a "vals" variable | |
var vals = form.vals(); | |
// now we can push to the dataLayer | |
dataLayer.push({ |
OlderNewer