Title: Send event in function
Last modified: August 22, 2016

---

# Send event in function

 *  Resolved [Nic](https://wordpress.org/support/users/nick-v/)
 * (@nick-v)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/send-event-in-function/)
 * Hi,
 * Is-it possible to send an event to Slimstat from a Javascript function. I use
   Jquery to verify some conditions. If they are true, i would like to log a hit.
   I use Slimstat 3.6.8.
 * Thank you,
 * Nicolas Pelletier
 * [https://wordpress.org/plugins/wp-slimstat/](https://wordpress.org/plugins/wp-slimstat/)

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

 *  [Chris Lloyd](https://wordpress.org/support/users/chrisl27/)
 * (@chrisl27)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/send-event-in-function/#post-5194995)
 * Hi,
 * That info’s in the FAQ: [https://wordpress.org/plugins/wp-slimstat/faq/](https://wordpress.org/plugins/wp-slimstat/faq/)
   
   Under “Can I track clicks and other events happening on the page?”
 *  Plugin Contributor [Jason Crouse](https://wordpress.org/support/users/coolmann/)
 * (@coolmann)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/send-event-in-function/#post-5195007)
 * Thanks for chiming in, chrisl27 🙂
 *  Thread Starter [Nic](https://wordpress.org/support/users/nick-v/)
 * (@nick-v)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/send-event-in-function/#post-5195043)
 * 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,
 *  Plugin Contributor [Jason Crouse](https://wordpress.org/support/users/coolmann/)
 * (@coolmann)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/send-event-in-function/#post-5195045)
 * In your case, you need to pass the variable to the function:
 * `blur(function(event){...`
 * That should work 😉
 *  Thread Starter [Nic](https://wordpress.org/support/users/nick-v/)
 * (@nick-v)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/send-event-in-function/#post-5195065)
 * 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.
 *  Plugin Contributor [Jason Crouse](https://wordpress.org/support/users/coolmann/)
 * (@coolmann)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/send-event-in-function/#post-5195066)
 * Again, you need to pass `event` to the function:
 * `.click(function(event){`
 * 🙂

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

The topic ‘Send event in function’ is closed to new replies.

 * ![](https://ps.w.org/wp-slimstat/assets/icon.svg?rev=2832242)
 * [SlimStat Analytics](https://wordpress.org/plugins/wp-slimstat/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-slimstat/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-slimstat/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-slimstat/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-slimstat/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-slimstat/reviews/)

 * 6 replies
 * 3 participants
 * Last reply from: [Jason Crouse](https://wordpress.org/support/users/coolmann/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/send-event-in-function/#post-5195066)
 * Status: resolved