View Full Version : onClick tracking event for internal slides?

3 Sep 2012, 9:36 PM
Hi Guys

I'm trying to integrate an onClick event that fires a tracking code just like a Google event tracker, I want to implement that for the buttons that use the function "Go To Scene" or any other function.

So basically the onClick event format is:

onClick="Snakk.log('Address','Title', 'click');"

Basically I want to be able to track how many people clicked or entered a specific slide.

I'm pretty sure that I can do that by implementing a custom JS for the button to go to the other scene and then fire off the onClick event. Problem is that I haven't worked with Sencha for a year now and getting rusty with the syntax. Thanks


4 Sep 2012, 1:16 AM
Hi there,

With the latest 1.3 release, we also improved the documentation of JS functions that are available when editing custom JS. You can find it here: http://docs.sencha.com/animator/1-3/#!/guide/advanced_js

To achieve what you are trying to do, you indeed need to set the click event to custom JS and then enter following:

//your tracking code

//go to next scene code

Alternatively, you can also skip to another scene by using:




The auto-substitution in the editor will list scene_id's / scene_names as you type.

Finally, don't forget to include the definition of your tracking code function in the project header.

Hope it helps, and good luck with your project.

4 Sep 2012, 3:51 PM
Hi miro

Actually that doesn't work, there is no way i can think off that can initiate an onClick event in sencha animate! Arne?


5 Sep 2012, 7:44 AM
That should work :)

Basically, you can set the click action in Animator for the object to custom JS and then you can call all the functions you want, like Miro described.

If you are still having issues with it, could you describe what is not working?

5 Sep 2012, 2:27 PM
Hi Arne

When placing the click action before the controller.goToNextScene...etc the button refuses to execute.

I've tried the following


None of the above works. I've looked at the event tracking documentation (http://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide) for google analytics, the only way I could find was through an onClick function. There is another method that is suitable for Flash ActionScript only!


5 Sep 2012, 2:42 PM
Sounds like your call to the tracking results in an error, hence the go to next scene is never reached.

From the page you linked, here is an example of how to call google analytics from the code.

_gaq.push(['_trackEvent', 'Videos', 'Play', 'Baby\'s First Birthday']);

//and then you could call the controller

Note that in order to user libraries such as google analytics you need to load the library itself. Also, for better error messages you can open up the developer inspector in chrome and check the console for any error statements.