Hi,
That info’s in the FAQ: https://wordpress.org/plugins/wp-slimstat/faq/
Under “Can I track clicks and other events happening on the page?”
Thanks for chiming in, chrisl27 🙂
Thread Starter
Nic
(@nick-v)
Hi,
I can send data to Slimstat directly on an event (click, mouseover, focus, keypress) like it is explained in the documentation. It works, but when i take the exact same code and put it in a more complex function, it stops working. The problem is not in my function because if i replace the Slimstat line by something else, it is executed. Here’s my code :
`$( document ).ready(function(){
var hover_youtube = false;
var libelle_evenement = “”;
$(“iframe”).hover(
function() {
hover_youtube = true;
}, function() {
hover_youtube = false;
}
);
$(window).blur(function() {
if(hover_youtube == true) {
SlimStat.ss_track(event, 5, ‘clicked on first link’);
hover_youtube = false;
}
});
});`
Thank you,
In your case, you need to pass the variable to the function:
blur(function(event){...
That should work 😉
Thread Starter
Nic
(@nick-v)
I’ve simplified the code before posting it here, but because your plugin is very good at certain things and Google Analytics at others, i send event to the two in the same code. Google receive my data so in a way, the code works.
I’ve programmed a very simple function to be sure of my point.
This works :
<a onclick="SlimStat.ss_track(event, 5, 'clicked on first link');" href="https://www.youtube.com/">A link!</a>
This does’nt (the function is executed on the click, but the event not sent):
$(“a”).click(function() {
SlimStat.ss_track(event, 5, ‘clicked on first link’);
});
The line that send the event is the same and is a copy/paste form the documentation.
The reason i wan’t to use JQuery is that i could write a “listener” function and not have to write an onclick for every link.
Thank you for your time and for the great plugin.
Again, you need to pass event to the function:
.click(function(event){
🙂