I'm struggling to make this script work. What I'm looking to achieve is to use Event Tracking on Google Analytics on how to pass what slide of the slidedeck is being viewed.
The jQuery code for the Slidedeck (and it's API: http://www.slidedeck.com/actions/) I'm using to track the event is:
$('#nextArrow').click(function() {
$('.slidedeck').slidedeck().next({
before: function(deck){
// Alert the current slide number before animating
},
complete: function(deck){
alert(deck.current); // Alert the current slide number after animating
}
});
});
This successfully alerts me which slide is being viewed after the next button has successfully animated to the next slide, by using Slidedecks API deck.current
What I need to do is convert this to something along these lines.
$('#SSnext').click(function() {
$('.slidedeck').slidedeck().next({
before: function(deck){
// Alert the current slide number before animating
},
complete: function(deck){
var slideNumber = function(deck){(deck.current)};
_gaq.push(['_trackEvent', 'slidedeck', 'slides', slideNumber]);
}
});
});
But this doesn't work. I think I'm getting this bit very wrong:
complete: function(deck){
var slideNumber = function(deck){(deck.current)};
_gaq.push(['_trackEvent', 'slidedeck', 'slides', slideNumber]);
}
If anyone can shed some insight on how to pass the variable to the gaq_push string for Google Analytics, that'd be awesome.
I'm not sure why you're making slideNumber a function in the 2nd example. You should simply pass deck.current to it instead. Try the following code:
That should work correctly.