Created
September 25, 2013 19:56
-
-
Save hsquareweb/6705149 to your computer and use it in GitHub Desktop.
JS: GA Event Tracking
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
//GOOGLE EVENTS TRACKING | |
var track = function(category, name, value) { | |
// console.log(category); | |
// console.log(name); | |
// console.log(value); | |
// return; | |
if (window._gaq) { | |
window._gaq.push(["_trackEvent", category, name, value]); | |
} | |
}; | |
$(document).ready(function(){ | |
$(document).on("click", "#branding .more", function(){ //Branding area more links | |
var ad = $(this).attr("title"); | |
var spot = window.location.href; | |
var gaLabel = $(this).siblings('.sfitemTitle').text().trim(); | |
track('Branding Area', 'More Link', gaLabel); | |
}).on("click", "#branding .slide:first-child a", function(){ //Branding Area first slide | |
var ad = $(this).attr("title"); | |
var spot = window.location.href; | |
track('Branding Area', 'Apply Today', 'The first apply today branding image'); | |
}).on("click", ".header .login a", function(){ //Header utility login link | |
var ad = $(this).attr("title"); | |
var spot = window.location.href; | |
track('Header', 'Login Link', 'Header utility login link'); | |
}).on("click", ".featured .btn", function(){ //Featured Buttons | |
var ad = $(this).attr("title"); | |
var spot = window.location.href; | |
var gaLabel = $(this).text().trim(); | |
track('Featured Area', 'Button Link', gaLabel); | |
}).on("click", ".loginBox a", function(){ //LoginBox on homepage | |
var ad = $(this).attr("title"); | |
var spot = window.location.href; | |
var gaLabel = $(this).text().trim(); | |
track('Login Box', 'Button Link', gaLabel); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment