Infinite scrolling and Google Analytics
If you want to keep track of all the pages viewed by the user with YITH Infinite scrolling with Google Analytics, just:
- Make sure you have enabled the option "Change the URL of the page whenever new items are loaded" from YITH> Infinite Scrolling> Settings
- Add the following code to the "Custom JavaScript" box ( YITH> Infinite Scrolling> Settings ):
(function($) { $(document).on( 'yith_infs_url_changed', function( ev, url ){
if( url == location.pathname && typeof ga != 'undefined' ) {
ga('set', 'page', location.pathname);
ga('send', 'pageview');
}
});
})(jQuery);