Skip to content

Instantly share code, notes, and snippets.

@kovshenin
Created January 14, 2014 14:39
Show Gist options
  • Save kovshenin/8419292 to your computer and use it in GitHub Desktop.
Save kovshenin/8419292 to your computer and use it in GitHub Desktop.
var $button = jQuery( '#my-button' ),
test = Math.floor((Math.random()*2)+1);
if ( test == 1 )
$button.css( 'background', '#ff0000' ).data( 'test-value', 'red' );
else
$button.css( 'background', '#0000ff' ).data( 'test-value', 'blue' );
_gaq.push(['_trackEvent', 'My Button', 'Show', $button.data( 'test-value' )]);
$button.on( 'click', function() {
_gaq.push(['_trackEvent', 'My Button', 'Click', $button.data( 'test-value' )]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment