Skip to content

Instantly share code, notes, and snippets.

View ortense's full-sized avatar
💀
Coding...

Marcus Ortense ortense

💀
Coding...
View GitHub Profile
@ortense
ortense / analytics.js
Created May 4, 2014 00:51
Código padrão do universal analytics
(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-XXXX-Y', 'auto');
ga('send', 'pageview');
@ortense
ortense / google-analytics-form-interaction.js
Last active October 18, 2018 05:19
Google Analytics Track Form Interactions
(function($){
var forms = $("form");
forms.on("submit", function(){
var form = $(this);
ga("send", "event", "forms",
form.attr("name") || form.attr("id"),
"submit";
);
@ortense
ortense / google-analytics-track-scroll-end.js
Last active August 29, 2015 14:00
Google Analytics Track Scroll End
(function($){
var $window = $(window),
$document = $(document),
scrollEnd = function(){
if(($window.height() + $window.scrollTop() + 20) >= $document.height()){
ga("send", "event", "scroll", document.location.pathname, "100%");
$window.off("scroll", scrollEnd);
}
};
$window.on("scroll", scrollEnd);
@ortense
ortense / google-analytics-track-first-click.js
Created May 5, 2014 00:39
Google Analytics Track First Click
(function($){
var links = $("a"),
fistClick = function(){
var link = $(this);
ga("send", "event",
"first-click",
document.location.pathname,
link.text() + "|" + link.attr("href")
);
@ortense
ortense / google-analytics-track-external-links.js
Created May 5, 2014 00:58
Google Analytics Track External Links
/* ==|=======================================================================
Grid // http://semantic.gs/
========================================================================== */
/* Altere estes valores de acordo com a largura das colunas,
largura das margens e o número de colunas do seu grid.*/
@column-width: 60;
@gutter-width: 20;
@columns: 12;

The HTML5 Amount of Awesomeness

Rainbox Vomit

A collection of freaking awesome HTML5 demos (work in progress).

WebGL

@ortense
ortense / google-analytics-track-youtube.coffee
Last active August 29, 2015 14:01
Google Analytics Track Youtube Interactions
do (window, document) ->
iframes = document.getElementsByTagName("iframe")
youTubeIframes = []
regex = /.*youtube.*\/(embed|v)\/(.+)\?.*/
window.youtube = window.youtube or {}
youtube.movies = youtube.movies or {}
category = youtube.movies.category = if youtube.movies.category then youtube.movies.category else "youtube"
@ortense
ortense / bitLy.js
Created May 13, 2014 16:31
Function to shorten url by bit.ly
/**
* @function bitLy
* @param {string} long_url - Long URL to shorten
* @param {function} func - receives short url
*/
function bitLy(long_url, func){
$.getJSON(
"http://api.bitly.com/v3/shorten?callback=?",
{
"format": "json",
@ortense
ortense / redirect.jsp
Created May 13, 2014 20:45
Redirect page in JSP
<%
String requestURL = request.getRequestURL().toString();
String queryString = request.getQueryString();
String redirectUrl = "http://redirect.to/path";
if (queryString != null) redirectUrl += "?" + queryString;
response.setStatus(301);
response.setHeader( "Location", redirectUrl);
response.setHeader( "Connection", "close" );
%>