// linkTracking - Tracking various link clicks through Google Analytics
// Requires jQuery, Google analytics
 
$(document).ready(function() {
 
	/*
		Track External Link Clicks 
 
		Add the attribute rel="external" to any external link
		on your site, and this function will track the click. 
 
		Click reported as: /custom-tracking/outgoing-link/{url of link clicked}
	*/	
 
	$('a[rel="external"]').click(function(){
		customLink = '/custom-tracking/outgoing-link/' + $(this).attr('href');
		pageTracker._trackPageview(customLink);
	});	
 
/* =================================================================== */

	/*
		Track Navbar Link Clicks 
 
		Add the attribute rel="navbar" to any external link
		on your site, and this function will track the click. 
 
		Click reported as: /custom-tracking/navbar/{url of link clicked}
	*/	
 
	$('a[rel="navbar"]').click(function(){
		customLink = '/custom-tracking/navbar/' + $(this).attr('href');
		pageTracker._trackPageview(customLink);
	});	

/* =================================================================== */

	/*
		Track Subnav Link Clicks 
 
		Add the attribute rel="subnav" to any external link
		on your site, and this function will track the click. 
 
		Click reported as: /custom-tracking/subnav/{url of link clicked}
	*/	
 
	$('a[rel="subnav"]').click(function(){
		customLink = '/custom-tracking/subnav/' + $(this).attr('href');
		pageTracker._trackPageview(customLink);
	});	
 
/* =================================================================== */
 
	/*
		Track Email Link Clicks
 
		This simply tracks the click on any link that uses
		the "mailto:email@domain.com" method.
 
		Click reported as: /custom-tracking/email-link/mailto:{email address clicked}
	*/
 
	$('a[href*=mailto]').click(function () {
		customLink = '/custom-tracking/email-link/' + $(this).attr('href');
		pageTracker._trackPageview(customLink);
	});
 
/* =================================================================== */
 
	/*
		Track PDF File Downloads
 
		This adds the tracking code to any link with a .pdf extension, allowing
		you to track file downloads
 
		Click reported as: /custom-tracking/pdf-link/{url of pdf clicked}
	*/
 
	$('a[href*=.pdf]').click(function () {
		customLink = '/custom-tracking/pdf-link/' + $(this).attr('href');
		pageTracker._trackPageview(customLink);
	});
 
/* =================================================================== */
 
	/*
		Track Custom Page Elements
 
		If you want to track anything specific, this will allow you
		to do so anywhere you want.
 
		To use this:
		- add a class of "customTracker" to your link.
		- add a title attribute to your link to be used in your reports
 
		For example: <a class="customTracker" title="Log in to your account" href="{some url">Click here to log in</a>
		Would report as /custom-tracking/page-element/Log in to your account
	*/
 
	$('a.customTracker').click(function(){
		customLink = '/custom-tracking/page-element/' + $(this).attr('title');
		pageTracker._trackPageview(customLink);
	});	
 
/* =================================================================== */
 
	/*
		Alter tracking of Blue State Digital Links
 
	*/
 
	$('a[href*=action.seiu.org]').click(function () {
		customLink = '/custom-tracking/action.seiu.org/' + $(this).attr('href');
		pageTracker._trackPageview(customLink);
	});
 
/* =================================================================== */
 
});
