This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gaForm = gaForm || {}; | |
jQuery(function($) { | |
var defaults = { | |
Forms:"#form", | |
Category:"analysisForm", | |
Action:"id", | |
inputRadio: true, | |
inputSelect: true, | |
inputCheckBox: true | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (typeof jQuery != 'undefined') { | |
jQuery(document).ready(function($) { | |
var filetypes = /\.(zip|exe|dmg|pdf|doc.*|xls.*|ppt.*|mp3|txt|rar|wma|mov|avi|wmv|flv|wav)$/i; | |
var baseHref = ''; | |
if (jQuery('base').attr('href') != undefined) baseHref = jQuery('base').attr('href'); | |
jQuery('a').on('click', function(event) { | |
var el = jQuery(this); | |
var track = true; | |
var href = (typeof(el.attr('href')) != 'undefined' ) ? el.attr('href') :""; |