Title: Adding Google Analytics to Jetpack Carousel
Last modified: August 24, 2016

---

# Adding Google Analytics to Jetpack Carousel

 *  Resolved [eleganteye](https://wordpress.org/support/users/eleganteye/)
 * (@eleganteye)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-google-analytics-to-jetpack-carousel-1/)
 * I’ve done this: [http://jetpack.me/2013/10/09/javascript-events-carousel/](http://jetpack.me/2013/10/09/javascript-events-carousel/)
 * It shows me a ton of data in the console.
 * How do I isolate the path and filename of the image, so I can send it to Google
   Analytics as a view?
 * [https://wordpress.org/plugins/jetpack/](https://wordpress.org/plugins/jetpack/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Jeremy Herve](https://wordpress.org/support/users/jeherve/)
 * (@jeherve)
 * Jetpack Mechanic 🚀
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-google-analytics-to-jetpack-carousel-1/#post-6072294)
 * I would suggest that you try what’s suggested [here](https://wordpress.org/support/topic/adding-google-analytics-to-jetpack-carousel?replies=3&view=all#post-5938569),
   that should do the trick!
 *  Thread Starter [eleganteye](https://wordpress.org/support/users/eleganteye/)
 * (@eleganteye)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-google-analytics-to-jetpack-carousel-1/#post-6072377)
 * ga(‘send’, ‘pageview’) will have already been sent through the normal tracking
   code. Because carousel doesn’t load a new page, I don’t think it will be sent(
   at least I don’t see it watching live data on my site)
 * I think what needs to be done is:
 * ga(‘send’, ‘event’, ‘gallery’, ‘click’, image/path/filename);
 * I have tried this with hard-coded generic data ‘image’ But how do I put the actual
   image/path/filename into a variable?
 *  Plugin Author [Jeremy Herve](https://wordpress.org/support/users/jeherve/)
 * (@jeherve)
 * Jetpack Mechanic 🚀
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-google-analytics-to-jetpack-carousel-1/#post-6072408)
 * You could try to use something like [this](http://www.jquerybyexample.net/2012/06/get-url-parameters-using-jquery.html)
   to grab the Carousel ID that’s added to the URL when switching between images.
   Would that work for you?
 *  Thread Starter [eleganteye](https://wordpress.org/support/users/eleganteye/)
 * (@eleganteye)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-google-analytics-to-jetpack-carousel-1/#post-6072409)
 * Thank you for the help. The following is what I did and it is working. Note to
   others: You must replace “example.com” and use your own google analytics ID (
   UA-xxx…).
 * The ga(‘create’, may be redundant because it’s probably in your page footer tracking
   code already. I’m not a Google Analytics expert, so I’m not sure if you need 
   one for each click on a page.
 *     ```
       jQuery(document).on( 'jp_carousel.selectSlide', '.jp-carousel-wrap', function( event, slides ) {
   
       // pass value to google analytics
       ga('create', 'UA-xxxx-1', 'example.com');
       ga('send', 'pageview', { 'page': location.pathname + location.search + location.hash});	
   
       } );
       ```
   
 * That puts the full path including the anchor (#) tag into GA. Something like:
   /
   dir/subdir/pagename/#jp-carousel-1744 — This way you can take a look at your 
   most popular images, trace what people look at next, and even figure out what
   images they are skipping.
 * Because I have a child theme (as most trying this will) I needed “get_stylesheet_directory_uri”
   in the following (a variation from many examples) to enqueue in my theme_functions.
   php (vantage_child is just the name of my theme). I used the browser console 
   to debug path errors for the missing script.
 *     ```
       /**
        * enqueue script
        */
       function vantage_child_scripts() {
       	wp_enqueue_script( 'carousel-analytics',  get_stylesheet_directory_uri() . '/js/carousel-analytics.js', array(), '1.0.0', true );
       }
   
       add_action( 'wp_enqueue_scripts', 'vantage_child_scripts' );
       ```
   
 *  [erocha](https://wordpress.org/support/users/erocha/)
 * (@erocha)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/adding-google-analytics-to-jetpack-carousel-1/#post-6072591)
 * Hi eleganteye,
 * nice. Thanks a lot.
 * Enrique

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Adding Google Analytics to Jetpack Carousel’ is closed to new replies.

 * ![](https://ps.w.org/jetpack/assets/icon.svg?rev=2819237)
 * [Jetpack - WP Security, Backup, Speed, & Growth](https://wordpress.org/plugins/jetpack/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/jetpack/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/jetpack/)
 * [Active Topics](https://wordpress.org/support/plugin/jetpack/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/jetpack/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/jetpack/reviews/)

 * 5 replies
 * 3 participants
 * Last reply from: [erocha](https://wordpress.org/support/users/erocha/)
 * Last activity: [10 years, 7 months ago](https://wordpress.org/support/topic/adding-google-analytics-to-jetpack-carousel-1/#post-6072591)
 * Status: resolved