I have a swipe functionality on my mobile page, and I want to used touchstart, touchend, and touchmove to track the swipe functionality across the device without affecting the scrolling.
Here is my code.
jQuery('.first-frame').bind('touchmove', function(event) {
_gaq.push(['_trackEvent', 'Landing-Page', 'Swipe-Toggle-Color', '0259_2190']);
});
I know you asked for a touchmove, touchend, and touchstart example but I would use a combination of HammerJS (https://github.com/EightMedia/hammer.js/) and custom Google events to take the guess work out of it.
If it's possible to only monitor the
swipeleft
andswiperight
events in jQuery Mobile instead, do so.Otherwise, you can set a global variable on the
scroll
event that resets after, say, 0.2 seconds. Then have thetouchmove
event check if that variable is set, and if it is, don't trigger Google Analytics.