Skip to content

Instantly share code, notes, and snippets.

@SoerenS
SoerenS / gist:94529bc2b87667727ca3
Created June 11, 2015 14:48
JS Bookmarklet to add Analytics Tracking parameters to an URL
javascript:(function moo() {
var utm = "utm_source=facebook&utm_medium=social&utm_campaign=XXX";
var d = new Date();
var url = document.location.href;
utm += (""+d.getFullYear()).slice(-2) + ("0"+(d.getMonth()+1)).slice(-2) + ("0"+(d.getDay()+1)).slice(-2) + ("0"+(d.getHours()+1)).slice(-2) + ("0"+(d.getMinutes()+1)).slice(-2);
if (document.location.href.indexOf('#')>-1 && !document.location.href.indexOf('?')>-1){ url = url.replace("#", "?"+utm+"#"); }
else if (document.location.href.indexOf('#')>-1 && document.location.href.indexOf('?')>-1){ url = url.replace("#", "&"+utm+"#"); }
else if (document.location.href.indexOf('?')>-1){ url += "&" + utm; }
else{ url += "?" + utm; }
document.location.href = url;
@SoerenS
SoerenS / gist:1767984
Created February 8, 2012 10:25
Javascript code to disable graphs in Google Analytics
javascript:(function(e,a,g,h,f,c,b,d){if(!(f=e.jQuery)||g>f.fn.jquery||h(f)){c=a.createElement("script");c.type="text/javascript";c.src="https://ajax.googleapis.com/ajax/libs/jquery/"+g+"/jquery.min.js";c.onload=c.onreadystatechange=function(){if(!b&&(!(d=this.readyState)||d=="loaded"||d=="complete")){h((f=e.jQuery).noConflict(1),b=1);f(c).remove()}};a.documentElement.childNodes[0].appendChild(c)}})(window,document,"1.3.2",function($,L){$('[id$="ID-graph"]').toggle();$('[id$="-segmentExplorer"]').toggle();$('[id$="-table-tableControl"]').parent().toggle();$('[id$="graphFilteringDisclaimer"]').toggle();$('[id$="graphOptions"]').toggle();$('[id$="graphMode"]').toggle();$('[id$="-graphOptions"]').parent().toggle();});