Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fitsum/5978638 to your computer and use it in GitHub Desktop.
Save fitsum/5978638 to your computer and use it in GitHub Desktop.
Push URLs with .ppt | .doc | .pdf
<script type="text/javascript">
$(document).ready(function(){
$('a').on('click',function(){
var $href = $(this).attr('href');
var $pptDoc = new RegExp(".ppt$").test($href);
var $wordDoc = new RegExp(".doc$").test($href);
var $pdfDoc = new RegExp(".pdf$").test($href);
var $docType;
function push2GA(thisURL,thisOptValue){
_gaq.push(['_trackEvent', 'Download', thisURL, thisOptValue]);
}
if($pptDoc){$docType = "PowerPoint"; push2GA($href,$docType)}
else if($wordDoc){$docType = "Word Document"; push2GA($href,$docType)}
else if($pdfDoc){$docType = "Adobe Acrobat PDF"; push2GA($href,$docType)}
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment