Skip to content

Instantly share code, notes, and snippets.

@Shoora
Shoora / ua.js
Last active February 15, 2019 00:00 — forked from hatzopoulos/ua.js
Enhanced Link Attribution
// optimized http://mathiasbynens.be/notes/async-analytics-snippet#universal-analytics
(function(G,o,O,g,l){G.GoogleAnalyticsObject=O;G[O]||(G[O]=function(){(G[O].q=G[O].q||[]).push(arguments)});G[O].l=+new Date;g=o.createElement('script'),l=o.scripts[0];g.src='//www.google-analytics.com/analytics.js';l.parentNode.insertBefore(g,l)}(this,document,'ga'));
ga('create','UA-XXXXXXXX', 'auto');
// Enhanced Link Attribution:
// https://developers.google.com/analytics/devguides/collection/analyticsjs/advanced#enhancedlink
// https://support.google.com/analytics/answer/2558867?hl=en
ga('require', 'linkid', 'linkid.js');
@Shoora
Shoora / async_load.js
Last active February 28, 2019 03:35 — forked from devfred/async_load.js
Load javascript resources asynchronously. Accepts additional parameters that can be passed to the specified callback function
/**
* Load javascript resources asynchronously. Accepts additional parameters that can be passed to the specified callback function
* Author: Frederick King
* Date: 3/8/2012
* References/Credits : http://css-tricks.com/thinking-async/ , http://mathiasbynens.be/notes/async-analytics-snippet
*
**/
var async_load_js = function( url, callback ){
var js, args, rs, s;
@Shoora
Shoora / lazy_load.html
Last active February 28, 2019 03:47 — forked from NathanGRomano/lazy_load.html
LazyLoading
<html>
<head>
<title>LazyLoading Test</title>
<script>
var AsyncLoader = function(src, cb) {
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = src + '?=' + Math.random(); // make sure we are loading this once
if(typeof(cb) == 'function') {
@Shoora
Shoora / async_load.js
Last active February 28, 2019 03:35 — forked from james2doyle/async_load.js
async_load.js
(function() {
function async_load(){
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = 'http://yourdomain.com/script.js';
var x = document.getElementsByTagName('script')[0];
x.parentNode.insertBefore(s, x);
}
if (window.attachEvent) {
@Shoora
Shoora / jquery.gaformanalysis.js
Last active April 21, 2019 18:35 — forked from hidesakai/jquery.gaformanalysis.js
jquery.gaformanalysis
var gaForm = gaForm || {};
jQuery(function($) {
var defaults = {
Forms:"#form",
Category:"analysisForm",
Action:"id",
inputRadio: true,
inputSelect: true,
inputCheckBox: true
};
@Shoora
Shoora / Tracker.js
Last active February 28, 2019 03:59 — forked from juriansluiman/Tracker.js
Create a Tracker module for Google Analytics This tracker enables to track clicks on links and submits on forms. Usually * these events will not be recorded as the window.location is changed and the * request to Google Analytics is cancelled. This module prevents default * behaviour, tracks the Google Analytics event and then continues the link/…
/**
* Create a Tracker module for Google Analytics
*
* This tracker enables to track clicks on links and submits on forms. Usually
* these events will not be recorded as the window.location is changed and the
* request to Google Analytics is cancelled. This module prevents default
* behaviour, tracks the Google Analytics event and then continues the link/submit.
*
* Data attributes are used to augment the event with category/action/label values.
* Use them as "data-track-category", "data-track-action" and "data-track-label".
@Shoora
Shoora / analytics.ajax.html
Last active February 28, 2019 03:26 — forked from joseadrian/analytics.ajax.html
analytics.ajax.html
<!--
Ejemplo:
Página: dominio/formulario
API: analytics.js
-->
<script>
(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)
@Shoora
Shoora / form-submit-tracking-1.js
Last active February 28, 2019 03:38 — forked from andregoncalves/form-submit-tracking-1.js
form-submit-tracking-1
$("form").on('submit', function(e) {
var form = this;
if (_gaq) {
e.preventDefault();
_gaq.push(['_trackEvent', 'my category', 'my action']);
setTimeout(function() { form.submit(); }, 100);
return false;
}
@Shoora
Shoora / gist:68a77aa863ce3e379425
Last active February 28, 2019 03:41 — forked from padicode/gist:5318608
I modified the script to make it work with the new analytics.js - Universal Analytics that Google Analytics is due to launch in 2013. I also added minor changes to the logic. Any suggestions for optimization are welcomed
<script>
/*
The original script for the current Google Analytics tracking code is provided by Justin Cutroni: http://cutroni.com/blog/2012/02/21/advanced-content-tracking-with-google-analytics-part-1/
I modified the script to make it work with the new analytics.js - Universal Analytics that Google Analytics is due to launch in 2013.
I also added minor changes to the logic. Any suggestions for optimization are welcomed.
*/
jQuery(function($) {
// Debug flag
var debugMode = false;
@Shoora
Shoora / jquery.link-tracking-ga.js
Last active February 28, 2019 03:47 — forked from simondahla/jquery.link-tracking-ga.js
jquery.link-tracking-ga