Google Analytics Event Tracking for CRO and UX by Angie Schottmuller

Dynamically track optimization audit data for user behaviors like bounce (ABR) and scrolling along with clicks on tabs, file downloads, jump-to buttons, email address links, phone click-to-call, and external domain links.

by Angie Schottmuller

JavaScript

/*
Source URL:  http://j.mp/gaeventtrackingforcro
Minified Version:  http://j.mp/gaeventtrackingforcroMIN
            ________                        
       _,.-Y  |  |  Y-._                    
   .-~"   ||  |  |  |   "-.                 
   I" ""=="|" !""! "|"[]""|     _____      
   L__  [] |..------|:   _[----I" .-{"-.  
  I___|  ..| l______|l_ [__L]_[I_/r(=}=-P   
 [L______L_[________]______j~  '-=c_]/=-^   
  \_I_j.--.\==I|I==_/.--L_]           
    [_((==)[`-----"](==)j               \
       I--I"~~"""~~"I--I                 "Conversion optimization is where it's AT-AT!" 
       |[]|         |[]|                 
       l__j         l__j              
       |!!|         |!!|              GOOGLE ANALYTICS EVENT TRACKING FOR CRO & UX
       |..|         |..|              by Angie Schottmuller, OCT 14, 2014. Last updated: SEP 28, 2015 
       ([])         ([])              May the Force be with you. 
       ]--[         ]--[              Got questions? Send me a tweet: http://twitter.com/aschottmuller
       [_L]         [_L]              
      /|..|\       /|..|\             
     `=}--{='     `=}--{='            
    .-^--r-^-.   .-^--r-^-.           
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

INSTRUCTIONS:  Include a script link to this JavaScript file just before the body end tag. Requires inclusion of Google Universal Analytics (JavaScript inside head tag) and jQuery (linked JS file before body end tag) to be loaded first.

Ensure HTML for all clickable links has a unqiue, intuitive id attribute (id='bottomctabutton') that can be referenced with the logged event.

TIP: This code should ideally be minified to reduce load performance time. Minified source: http://j.mp/gaeventtrackingforcroMIN
*/

  
/*
READING VIEW TIME  -------------------------------------------------------------------------
Purpose: Log user page viewing time at 3, 5 and 15 seconds. Code Author: Angie Schottmuller.
Note: By default, GA recognizes a logged event as an "interaction". As...