Skip to content

Instantly share code, notes, and snippets.

View OrenBochman's full-sized avatar
🏠
Working from home

Oren Bochman OrenBochman

🏠
Working from home
  • WMF
  • 09:48 (UTC +03:00)
View GitHub Profile
@OrenBochman
OrenBochman / clean_userID.js
Last active March 21, 2016 11:46
customising the analytics snippet to clean PII : remove userID from page path.js for standard page reporting
// Checks to see if the current user's userID is found in the URL, if it is, remove it.
var userID = ""; // (Note, this assume the user ID is stored in a variable called `userID`)
if (document.location.pathname.indexOf('user/' + userID) > -1) {
var page = document.location.pathname.replace('user/' + userID, 'user');
ga('send', 'pageview', page);
}
@OrenBochman
OrenBochman / cross_domain.js
Created March 21, 2016 11:44
customising the analytics snippet with autolinker plugin for cross domain support
ga('create', 'UA-1458255-7', 'auto', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', 'other-domain.com'] );
@OrenBochman
OrenBochman / big_snippet.js
Created March 21, 2016 12:23
highly customised universal analytics snippet with cross domain, cross device and autotracking support
<!-- Universal Analytics start -->
<script async src='path/to/autotrack.js'></script>
<script>
var userID = "123"; // (set the user ID here via php etc.)
function getClientID() {
return ga(function(tracker) {
var clientId = tracker.get('clientId');
});
}
@OrenBochman
OrenBochman / 01_enhanced_ecommerce_plugin.js
Last active July 5, 2023 18:39
Enhanced ecommerce snippets in universal analytics
//This command must occur after you create your tracker object and before you use any of the enhanced ecommerce specific functionality.
ga('require', 'ec');
//no plugin needed but you need to set up the datalayer
var dataLayer = window.dataLayer = window.dataLayer || []; dataLayer.push({ ... });
@OrenBochman
OrenBochman / 01_count_image_by_name.js
Created March 22, 2016 09:54
custom GTM javascript variables
// Variable Name: ImageCounter
function () {
return function (imageFileName) {
var count = 0;
var images = document.getElementsByTagName('img');
var i;
for (i = 0; i < images.length; i++) {
var filePathParts = (images[i].src || '').split('/');
var fileName = filePathParts[filePathParts.length - 1];
if (fileName === imageFileName) {
@OrenBochman
OrenBochman / gist:43030557ad904d090a4641f4bfd0aca4
Created May 6, 2016 08:18 — forked from debasishg/gist:8172796
A collection of links for streaming algorithms and data structures
  1. General Background and Overview
function main() {
/*
Make a copy of the spreadsheet listed below and save it to your own Google Drive.
Template - https://docs.google.com/spreadsheet/ccckey=0Ao4Qdm9yCtaGdHpiWmpYSWoxcE9Wd0dEV0xDY3l5UGc#gid=0
Take the url of your new spreadsheet and enter it in the ssURL field below
*/
var ssURL = "spreadsheet.com";
var codeURL = "https://s3.amazonaws.com/ppc-hero-tools/daily-metrics-log.js";
@OrenBochman
OrenBochman / button ripples.js
Last active August 22, 2016 07:04
polymer neon - hero animation
//handle clicks within a certain scope (say a template)
var scope = document.querySelector('template[is="dom-bind"]');
//ripple click target to full screen or at least container scopr
scope._onPolymerClick = function(event) {
this.$.list.sharedElements = {
'ripple': event.target,
'reverse-ripple': event.target
};
//handle click
@OrenBochman
OrenBochman / gist:c6c51ac2e75a7711e8a5c57e00001d00
Created August 22, 2016 07:06
Polymer: basic animated element
//implement NeonAnimatableBehavior behavior
// or Polymer.NeonAnimationRunnerBehavior if also reponsible for running the animation (ctrl)
Polymer({
is: 'my-animatable',
behaviors: [
Polymer.NeonAnimationRunnerBehavior //I am reponsible for running the animation
],
properties: {
animationConfig: {