×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Matt Parry
Added: Aug 23, 2016 3:57 PM
Modified: Aug 23, 2016 5:56 PM
Views: 12
Tags: jquey
https://api.jquery.com/jquery.data/
  1. // FOR JQUERY
  2.  
  3. $('.ev').click(function() {
  4.        
  5.          var hitType = $(this).data('hittype');
  6.          var eventCategory = $(this).data('eventcategory');
  7.          var eventAction = $(this).data('eventaction');
  8.          var eventLabel = $(this).data('eventlabel');
  9.    
  10. ga('send', {
  11.                 hitType: hitType,
  12.                 eventCategory: eventCategory,
  13.                 eventAction: eventAction,
  14.                 eventLabel: eventLabel
  15.                 });
  16.        
  17. });
  18.  
  19. // IN CODE
  20. // Can use with any tag
  21.  
  22. <?? data-event="ev" data-hittype="event" data-eventcategory="SSE_RAF_Participation" data-eventaction="click" data-eventlabel="Decline">
  23.  
  24.