1

I am using an owl carousel as a one page site, and each page of content is on a full screen carousel slide. I want to be able to track each slide as a Virtual PageView with Google Analytics - but I cannot work it out. Below is the code for my previous and next buttons - but the problem is that users can also 'swipe' on touch devices - so i need to be able to track both - where do i start!?

var owl = $('.owl-carousel');
owl.owlCarousel();

$(".next").click(function(){
owl.trigger('next.owl.carousel');
})
$(".prev").click(function(){
owl.trigger('prev.owl.carousel');
})
});

Thanks for any help you can give!!

1 Answer 1

1

Using v2 you can listen to "change.owl.carousel", like so:

var owl = $("#owl-example");

owl.on('change.owl.carousel', function(e) {
    if (e.namespace && e.property.name === 'position') {
        // GA push to track slide view event //
        // e.relatedTarget.relative(e.property.value) is the slide number
        //_gaq.push(['_trackPageview', '...']);*/
    }
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.