How to add JavaScript events to the Carousel view

Add this to your site’s js to enable events such as adding Google Analytics tracking code to individual Carousel slides:

jQuery(document).on( 'jp_carousel.selectSlide', '.jp-carousel-wrap', function( event, slides ) {
	// This is just to show you what values get passed in.  Delete it before going to production.
	if ( window.console ) {
		console.log( this );
		console.log( event );
		console.log( slides );
		console.log( slides[0] );
	}
	// Do whatever extra stuff you want here.
} );

You can read more about it here.

This entry was posted in Code snippets, Tips & Tricks and tagged , , . Bookmark the permalink.

Richard A. profile
Richard A.

Montreal-based Project Manager at @Transitapp : http://transit.app/ Huge metro fan, and creator of http://mexicometro.org

Explore the benefits of Jetpack

Learn how Jetpack can help you protect, speed up, and grow your WordPress site.

Get up to 50% off your first year.

Compare plans

Have a question?

Comments are closed for this article, but we're still here to help! Visit the support forum and we'll be happy to answer any questions.

View support forum
  • Enter your email address to follow this blog and receive news and updates from Jetpack!

    Join 112.4K other subscribers
  • Browse by Topic

  • %d bloggers like this: