Skip to content

Instantly share code, notes, and snippets.

View sperand-io's full-sized avatar

Chris Sperandio sperand-io

  • Stripe
  • SF
View GitHub Profile
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@sperand-io
sperand-io / index.md
Last active December 9, 2015 18:56
Installing V2 of Segment's iOS SDK

To build the SDK to be small and use the integrations server-side only, add the following to your Podfile:

  pod 'Analytics/Segmentio', '~> 2.0.9'
  ... and to add any individual bundled integrations:
  pod 'Analytics/GoogleAnalytics'
  pod 'Analytics/Mixpanel'
  ... // the subspecs for additional bundled integrations are all listed here:
  ... // https://github.com/CocoaPods/Specs/blob/master/Specs/Analytics/2.0.9/Analytics.podspec.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sperand-io
sperand-io / index.js
Created January 26, 2016 18:51
Track Link Dynamic Properties Example
// links are DOM element(s) (multiple or singular)
//
// var links = document.querySelectorAll('a');
// var links = document.getElementByTagName('#specificLink')
analytics.trackLink(links, 'Clicked Link', function(link) {
return {
url: link.href,
// analytics.page('Name', { returning: getNewOrRepeat() === 'repeat' })
function getNewOrRepeat() {
var session = 30; // minutes — feel free to change
var timeout = 30; // days — feel free to change
var cookie = '__nr' // cookie name — feel free to change
var now = new Date().getTime();
var day = 24 * 60 * 60 * 1000;
@sperand-io
sperand-io / snippet.html
Last active July 27, 2016 23:39
Set heap super props before initial page call
<script>
!function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","page","once","off","on"];analytics.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);e.unshift(t);analytics.push(e);return analytics}};for(var t=0;t<analytics.methods.length;t++){var e=analytics.methods[t];analytics[e]=analytics.factory(e)}analytics.load=function(t){var e=document.createElement("script");e.type="text/javascript";e.async=!0;e.src=("https:"===document.location.protocol?"https://":"http://")+"cdn.segment.com/analytics.js/v1/"+t+"/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(e,n)};analytics.SNIPPET_VERSION="3.1.0";
// add this line below
window.heap = window.heap ||
@sperand-io
sperand-io / instructions.md
Last active December 5, 2016 19:06
What Is Segment Sending on My Behalf?

If you have node installed, you can clone the repo for whichever integration you'd like to use (say GA) then install segmentio-facade:

git clone https://github.com/segmentio/integration-google-analytics.git
cd integration-google-analytics
npm install segmentio-facade

Then create a new file in the top level of the directory with the script from this gist.

Keybase proof

I hereby claim:

  • I am sperand-io on github.
  • I am sperandio (https://keybase.io/sperandio) on keybase.
  • I have a public key whose fingerprint is 8306 489A 5C3D 5795 190C D8BA BBC4 D1BD 40D1 8F90

To claim this, I am signing this object:

/**
* The node posix path parser implemented in ES2015
*
* regex from: https://github.com/nodejs/node/blob/master/lib/path.js#L406
*
* @param {String} path
* @return {Object} result
*
* let { name } = parse('/foo/bar/baz.html')
* // => name: baz
@sperand-io
sperand-io / index.html
Created July 18, 2015 02:31
Segment <-> Vimeo Tracking
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=700,maximum-scale=1.0,user-scalable=yes">
<title>Vimeo Froogaloop API Playground</title>
<script>
/* Don't forget your analytics.js snippet :) */
</script>
</head>
<body>