Created
May 15, 2014 16:52
-
-
Save paulmkoch/bac15329f7225663bba7 to your computer and use it in GitHub Desktop.
Event Category, Action, or Label of Existing Data Attribute
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
// replace the attribute with the appropriate data attribute | |
// if the attribute is divided with something other than commas, change tracking.split | |
// change the number to 0, 1, or 2, depending on whether you want the category, action, or label | |
function() { | |
var tracking = {{element}}.getAttribute('data-track-event'); | |
tracking = tracking.split(','); | |
if (typeof tracking === 'object') { | |
return tracking[0]; | |
} else { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment