Last active
December 20, 2015 20:49
-
-
Save morales2k/6193580 to your computer and use it in GitHub Desktop.
Google Analytics function for custom events for analytics.js
Use it anyway you want, from simply adding onclick attribute to an element other than <a> to track a click event. Easily customizable to make it track other stuff besides event hitType, or click action for that matter. See analytics.js documentation https://developers.google.com/analyt…
This file contains hidden or 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
/*! | |
* Tracking function to be used with the new analytics.js (i,s,o,g,r,a,m) snippet | |
* @param el string Identifier for the tracking click event | |
* @author Jorge L. Morales (EffectiX.Net) | |
* @return void | |
*/ | |
function gaTrack(el){ | |
ga('send', | |
{ | |
'hitType': 'event', | |
'eventCategory':el, | |
'eventAction':'click', | |
'eventLabel':el | |
} | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment