Skip to content

Instantly share code, notes, and snippets.

@kerotaa
Created September 16, 2013 23:04
Show Gist options
  • Save kerotaa/6587825 to your computer and use it in GitHub Desktop.
Save kerotaa/6587825 to your computer and use it in GitHub Desktop.
クリックカウントをdata属性で管理したいときに使う。
$('[data-ga-count]').on('click.ga', function() {
var $this = $(this),
data = $this.data('ga-count'),
splitter = ':';
if (data.indexOf(splitter) == -1 || $this.data('ga-counted')) return true;
$this.data('ga-counted', true);
data = data.split(splitter);
_gaq.push(['_trackEvent', data[0], 'click', data[1]]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment